15.2.0
OPTIMIZE FOR SLOW CONNECTIONS WITH cancel_on_exit
Want to optimize speed for users who scroll down fast on a slow connection? Just set cancel_on_exit: true and LazyLoad will cancel the download of images exiting the viewport while still loading, eventually restoring the original attributes.
- Introduced the new
cancel_on_exitoption. - Introduced the
callback_canceloption, just in case you want to perform any additional action whenever a download gets canceled bycancel_on_exit. - Created a new demo named
cancel_on_exit.htmlso you can try the newcancel_on_exitoption live. - Set
cancel_on_exittotruein the following demos, so you can test how it behaves...image_ph_inline.html, with an inline SVG placeholderimage_ph_external.html, with an external SVG placeholderdelay_test.html, in conjuction with thedelay_loadoptionfade_in.html, with a beautiful fade-in effect.
The cancel_on_exit option applies only to images so to the img (and picture) tags. It doesn't work for background images, iframes nor videos.
The cancel_on_exit option will probably default to true starting from the next major version, so give it a try! And please report your feedback in the comments of #438.
API
- Added the
resetElementStatus()method for when you need to tell LazyLoad to consider an image (or other DOM element) again. This is particularly useful if you change thedata-srcattribute after the previousdata-srcwas loaded). See the API section in the README file for more information.
FIX
- The
callback_exitcallback was called several times (for every images out of the viewport) at instance creation or uponupdate()calls. Now the callback is properly called only when any element exits the viewport.
INTERNALS
- Improved script performance by reducing the number of event listeners used for loading elements.
- Changed the values that the (internally used)
data-ll-statusattribute can take. Removed the status"observed"(it was useless) and introduced status"delayed".
Love this project? 😍 Buy me a coffee!