Hi Tim,
the videos are embedded via object elements, not iframes. That is the reason why Lazy Loader does not handle that. I will check if I can modify the plugin so that it also handles object elements.
Best,
Florian
Thanks Florian, I can always change the code to iframe if not. However, I have many other pages with video where iframe is used instead such as this one:
https://timbickvoiceover.co.uk/app-problem-explainers/
and those don’t seem to lazy load either.
Hi Tim,
for that video I see the lazyloaded class that is added by the lazyload script, and in the network tab of the browser dev tools, the initiator for the first request to youtube.com is the lazysizes script that is used by Lazy Loader.
Visually it seems that it is loaded right away because it is directly in the visible area. Do you have a page where an iframe video is more down below the page?
Best,
Florian
You’re right of course, the lazyload class is defined in the iframe on that page, sorry. What led me to the conclusion it wasn’t is that when I run Pagespeed Insights on it, it tells me that third party code is blocking the main thread for 560ms and shows the Youtube code as being the cause of that. Perhaps I’m just misunderstanding how lazyload works and expecting too much of it.
Anyway, I swapped my homepage objects for iframes (which are at the bottom of the page) and now the TBT is down to 0ms for that page so I’m very happy with that. Thank you.
Great, you’re welcome, and thanks for your donation!
»What led me to the conclusion it wasn’t is that when I run Pagespeed Insights on it, it tells me that third party code is blocking the main thread for 560ms and shows the Youtube code as being the cause of that. Perhaps I’m just misunderstanding how lazyload works and expecting too much of it.«
Lazy loading prevents things like iframes or images from slowing down the initial page load. But if they are in the visible area, they are loaded right after that, and maybe Google Pagespeed does not only check the initial load but also things that happen after that. But I am not sure about that.