GoogleChromeLabs / wp-native-lazyload

WordPress plugin to lazy-load media using the native browser feature.
https://wordpress.org/plugins/native-lazyload/
Apache License 2.0
51 stars 13 forks source link

Images don't load on Safari - How to disable lazyload on it? #21

Open Jany-M opened 4 years ago

Jany-M commented 4 years ago

Simply put, images load fine on any browser except Safari, which unfortunately still exists. Both on iOS and desktop.

Is there a way to disable lazyload for it? A filter maybe?

cr0ybot commented 4 years ago

[Duplicating my post from the WP plugin support forum]

I'm seeing (or, rather, not seeing) the same thing. Safari (13.0.5 (15608.5.11)) is not loading any images.

No errors or output of any kind in the console. The lazyload.js file is loaded, the images src attribute have all been replaced with the placeholder.svg, and the native-lazyload-js-fallback class is applied.

By the way, this is with SCRIPT_DEBUG on as well.

cr0ybot commented 4 years ago

I've sorted it out. I have a no-js class in my html element that for some reason is not being removed properly by my theme's JavaScript. Removing the no-js class fixes the issue.

FYI I made a silly mistake in my JS replacing the no-js class. I had:

document.documentElement.className.replace( /(?:^|\s)no-js(?!\S)/g, '');
document.documentElement.className += ' js';

The replace method returns a string, it does not act on it directly. It should be:

document.documentElement.className = document.documentElement.className.replace( /(?:^|\s)no-js(?!\S)/g, '') + ' js';