[wp-trac] [WordPress Trac] #56930: Block themes: improve omitting lazy-loading attribute on first content image/iframe
WordPress Trac
noreply at wordpress.org
Fri Oct 28 17:30:16 UTC 2022
#56930: Block themes: improve omitting lazy-loading attribute on first content
image/iframe
-----------------------------+-----------------------------
Reporter: adamsilverstein | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Media | Version: 5.9
Severity: normal | Keywords:
Focuses: performance |
-----------------------------+-----------------------------
In #53675 we improved core's auto application of the `loading="lazy"`
attribute for content images (and iframes). The behavior was adjusted to
avoid adding the `lazy` loading attribute to the first content image,
because that can actually slow down the speed/priority of that image being
loaded. Additional details are on
[https://make.wordpress.org/core/2021/07/15/refining-wordpress-cores-lazy-
loading-implementation/ this post].
Subsequent testing of the feature revealed that block theme images still
aren't handled correctly: all content images receive the `lazy` loading
attribute, including the first one.
This is caused by the block theme "double" pass at the `the_content`
(which can actually help performance ). To fix this we need to avoid
"counting" images (which we do to skip adding the lazy attribute to the
first image) the first pass by block themes where the $context is false .
During the actual content pass, the context value is `the_content`.
Testing instructions:
- Enable the twentytwentythree theme
- Create a post with two different images and view the post
- Note that currently both images have the loading="lazy" attribute
patch incoming, after this patch, the first image does not have the
loading="lazy"attribute
- test with a classic theme (eg twentyninetween) to verify the same
expected behavior
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56930>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list