[wp-trac] [WordPress Trac] #58773: Improve oEmbed lazy loading
WordPress Trac
noreply at wordpress.org
Thu May 2 00:10:19 UTC 2024
#58773: Improve oEmbed lazy loading
-------------------------------------+-------------------------------------
Reporter: adamsilverstein | Owner: adamsilverstein
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: 6.6
Component: Embeds | Version:
Severity: normal | Resolution:
Keywords: has-patch has-unit- | Focuses: performance,
tests | sustainability
-------------------------------------+-------------------------------------
Changes (by westonruter):
* milestone: Future Release => 6.6
Comment:
I think I have a solution for fixing lazy-loading of post embed iframes.
See https://github.com/WordPress/performance/pull/1192
I found that Chrome didn't reliably load the lazy-loaded post iframe when
it had the `clip: rect(1px, 1px, 1px, 1px)` style present. Strangely, the
iframe would load when navigating to the page but it wouldn't load when
reloading the page. However, if the `clip` is replaced with `opacity:0;
pointer-events:none;` then it works as expected. I tested in Chrome,
Safari, and Firefox. I've opened a PR to apply this change to core as
well: https://github.com/WordPress/wordpress-develop/pull/6474
When testing this, remember to insert three images into the post content
prior to the post embed. This I had to first insert 3 images into the
post content followed by the post embeds. This is because
`wp_omit_loading_attr_threshold()` returns 3 so that lazy-loading is only
applied to images and iframes after the 3rd.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/58773#comment:26>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list