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

Run lazy-loading initialize script on `DOMContentLoaded` #6

Closed felixarntz closed 5 years ago

felixarntz commented 5 years ago

Issue Overview

If the script is enqueued / printed in another location, it may be that some images do not get transformed so that they don't get a proper src attribute, causing them to not be loaded at all.

Possible Solution

By wrapping the script to run on DOMContentLoaded, it is ensured it catches all images initially included in the markup.

Potentially related (Autoptimize):