[wp-trac] [WordPress Trac] #53675: Omit lazy-loading attribute on first content image/iframe
WordPress Trac
noreply at wordpress.org
Mon May 22 19:11:51 UTC 2023
#53675: Omit lazy-loading attribute on first content image/iframe
-------------------------------------------------+-------------------------
Reporter: flixos90 | Owner: flixos90
Type: enhancement | Status: closed
Priority: normal | Milestone: 5.9
Component: Media | Version: 5.5
Severity: normal | Resolution: fixed
Keywords: has-patch has-unit-tests has-dev- | Focuses:
note | performance
-------------------------------------------------+-------------------------
Comment (by flixos90):
In [changeset:"55847" 55847]:
{{{
#!CommitTicketReference repository="" revision="55847"
Media: Conditionally skip lazy-loading on images before the loop to
improve LCP performance.
When the logic to exclude images that likely appear above the fold from
being lazy-loaded was introduced in WordPress 5.9, initially only images
that appear within the main query loop were being considered. However,
there is a good chance that images above the fold are rendered before the
loop starts, for example in the header template part.
It is particularly common for a theme to display the featured image for a
single post in the header. Based on HTTP Archive data from February 2023,
the majority of LCP images that are still being lazy-loaded on WordPress
sites use the `wp-post-image` class, i.e. are featured images.
This changeset enhances the logic in `wp_get_loading_attr_default()` to
not lazy-load images that appear within or after the header template part
and before the query loop, using a new `WP_Query::$before_loop` property.
For block themes, this was for the most part already addressed in [55318],
however this enhancement implements the solution in a more generally
applicable way that brings the improvement to classic themes as well.
Props thekt12, flixos90, spacedmonkey, costdev, zunaid321, mukesh27.
Fixes #58211.
See #53675, #56930.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/53675#comment:54>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list