This release addresses an issue caused by a recent change in browser behavior.
Previously LazilyLoaderPlugin
would use a MutationObserver
to set loading=lazy
on <img>
elements in supported browsers. This assumed they would respond to the added loading
attribute rather than begin loading their contents. Currently this strategy no longer works reliably. It's likely that browsers now pre-emptively download resources before the MutationObserver
even executes.
LazilyLoaderPlugin
now uses an attribute-swapping technique to cancel the image load before setting loading=lazy
. For maximum compatibility it performs the swap-back at the next execution loop via setTimeout()
. It's unclear to me how this affects performance on extremely asset-heavy pages. In a later release I'd like to improve this with a queue and a debouncing function.
v1.0.2 changes
Lazily
: Prevent exceptions when calling API methods in unsupported browsersLazilyLoaderPlugin
: Fix nativeloading=lazy
fallback in supporting browsers