Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

v1.0.2: Loading attribute hotfix

Latest
Compare
Choose a tag to compare
@nicross nicross released this 21 Jan 01:01
· 1 commit to master since this release

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 browsers
  • LazilyLoaderPlugin: Fix native loading=lazy fallback in supporting browsers