Thread Starter
roam92
(@roam92)
OK, so the solution is pretty simple.
Basically, the Rocket plugin should be adding this tiny piece of HTML code to every page where lazy loading is happening:
<noscript><style type="text/css">.rll-youtube-player,[data-lazy-src]{display:none !important;}</style></noscript>
Note this cannot go in a CSS style file, but likely needs to be put on every page on your site. You could accomplish that by adding it to a HTML widget or code snippet, or modifying your theme’s child template. I put it in my footer.
It’s basically telling the browser to not display the duplicate/empty placeholder boxes when JavaScript is turned off. They mess up the page layout.
Bottom line: This code really should go in the Lazy Load by WP Rocket plugin itself. It’s an easy no-brainer for no-JavaScript support, and probably was a simple oversight by the plugin authors, since everything else is in place for this to work.
Until it does go in, you can add it yourself.
(Disclaimer: No warranties expressed or implied 🙂
This is indeed missing, WP does add a no-js class in the body tag if JS is disabled, so something like this should be enough
<style type="text/css">.no-js .rll-youtube-player, .no-js [data-lazy-src]{display:none !important;}</style>
Thread Starter
roam92
(@roam92)
Hi,
Thank you for all your responses, as well as the plugin update with the fixes to various issues in the new 2.x release!
One question regarding the helpful CSS code you just posted. That’s great you can leverage a no-js class that already exists in WordPress.
But this small code fix does not yet appear to be incorporated into the plugin itself… Shouldn’t it be??
This CSS code is specific only to the WP-Rocket Lazy Load plugin, so don’t you want to include it so that the plugin will work without JavaScript for ALL users?
I can certainly see no harm in doing so, only benefits. Thanks!
It will be included in the next version of the plugin yes
Hi,
I’m interested in that functionality too.
Thanks.
By the way : great plugin thanks for encouraging a sustainable way to develop websites!
Thread Starter
roam92
(@roam92)
@wp_media
Wondering, did you actually test version 2.x with JavaScript turned off in your browser?
I just did, and it looks like it works the same as version 1.x did… meaning it doesn’t work well. No change really from the broken layout in version 1.x of the plugin, as far as I can tell.
TBH, I’m not certain that WordPress automatically adds a “no-js” class if JavaScript is disabled.
So, I restored my previous HTML hack from above, and things look OK again.
Any thoughts?? Thanks.