Make WordPress Core

Opened 8 weeks ago

#50756 assigned enhancement

Lazy-load iframes

Reported by: flixos90 Owned by: flixos90
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Media Keywords: needs-patch needs-unit-tests
Focuses: Cc:


As part of #44427, it was considered to lazy-load iframes in addition to images, however at that point the loading attribute on iframe tags was not yet formalized as part of the living HTML standard. This has changed a few weeks ago (see the iframe loading attribute), so we should consider adding a loading="lazy" attribute to iframes as well.

Likely the biggest surface area here will be oEmbed content, which is probably the most common way that WordPress sites include iframes.

We should generally try to follow a similar implementation like we did for images, relying on wp_lazy_loading_enabled() and wp_filter_content_tags(), which were intentionally built and named in a way that they are not limited to images only.

Another principle that we should follow is that the attribute should only be added to iframes which have width and height attributes specified.

This web.dev post provides more information on iframe lazy-loading.

Change History (0)

Note: See TracTickets for help on using tickets.