No bug JCHoptimize of iframes thwarts ochFitvids

More
4 years 8 months ago - 4 years 8 months ago #1482 by Tim Davis
Hi Ruud,

I have discovered that when JCHoptimize is set to lazy load iframes, och Fitvids does not work. Just letting you know.

Here is a sample iframe code with JCH lazyload fingerprints on it:
Code:
<div class="responsive-video"><iframe class="jch-lazyload" src="about:blank" data-src="https://www.youtube.com/embed/e9yE7ZyNUDs" width="560" height="315" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>
Last edit: 4 years 8 months ago by Tim Davis.

Please Log in to join the conversation.

More
4 years 7 months ago #1484 by Ruud van Lent
Replied by Ruud van Lent on topic JCHoptimize of iframes thwarts ochFitvids
Hi Tim,
JCH is known (at least for me) to rule the web as they are the only extension installed. When there are issues with extensions / plugins first question i ask is always is JCH Optimize installed: if yes, turn it off and see if that fixes the issue.

That said: What I see in the iframe code you provided, JCH is using a very 'old fashioned' lazyloading via a javascript. There are currently lazy loading standards introduced in all (modern) browsers that do not break the web.

JCH Optimize breaks the iframe by removing the src attribute. by doing that the iFrame cannot load because there is nothing to load. When the broken iFrame comes into to view, JCH repairs the iFrame by re-adding the src attribute.

Long ago, that was a very tricky lazy loading implementation. Since then the world has moved on and lazy loading is now a browser standard. You can simply add the loading="lazy" attribute to any iFrame and the browser will handle it as such.
like this:
Code:
<iframe src="video-player.html" title="..." loading="lazy"></iframe>

ochFitVids requires a intact iFrame as a broken iFrame is no iFrame :)

Please Log in to join the conversation.

More
4 years 7 months ago #1488 by Ruud van Lent
Replied by Ruud van Lent on topic JCHoptimize of iframes thwarts ochFitvids
Maybe I can have ochFitVids set the loading='lazy' element on iFrames it finds and processes. That way you have optimum sized videos AND lay loading conform latest standards (which Google likes as this is a standard I believe they introduced, or took part in).

Please Log in to join the conversation.