Problem/Motivation
Chrome now supports native lazy loading on iframes: https://web.dev/iframe-lazy-loading/
Steps to reproduce
Insert a YouTube video on a node and add display:none; on it.
The iframe is loaded even if not displayed.
Proposed resolution
video_embed_field should add a loading="lazy" attribute on iframes.
Issue fork video_embed_field-3359973
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
prudloff commentedComment #4
mably commented@prudloff do you think we should add a custom configuration option similar to the one used for image fields?
Comment #5
prudloff commentedI think the only case where we don't want lazy loading is when the iframe is near the top of the page.
This is common for images but might be less common for iframes, however I think having an option that is enabled by default would probably be best.
Comment #6
prudloff commentedComment #7
prudloff commentedI rebased the MR on 3.x but now some tests are failing.
Comment #8
mably commentedTests have been fixed.
But we are still missing that configuration option.
Comment #10
mably commented@prudloff could you have a look at my MR that adds the missing "loading" configuration option please? Thanks.
It also enables the "loading=lazy" feature for YouTube Playlist and Vimeo providers.
Comment #12
prudloff commentedI rebased the MR to fix conflicts.
I tried setting the loading option to lazy/eager on video fields and in CKE and everything seems to work correctly.
Comment #14
mably commentedGreat, let's merge this. Thanks for the review @prudloff!
Comment #16
mably commented