vanilla-lazyload
Advanced tools
Changelog
14.0.0
🎉 Major refactoring and performance improvement! 🔍 File size stays tiny: only 2.07 KB gZipped
Settings
callback_loading
is called when an element started loadingcallback_reveal
is now ⚠ DEPRECATED, use callback_loading
instead (it's the same thing, it was just renamed). callback_reveal
will be removed and will stop working in version 15.Instance methods
update()
method now also unobserves deleted elements, instead of just looking for and observing new elementsdestroy()
destroys better than it did before, delete
-ing properties instead of setting their values to null
load()
method (as an instance method) is now ⚠ DEPRECATED, use the static method instead. If you were using aLazyLoadInstance.load(element)
you should change it to LazyLoad.load(element, settings)
.Static methods
load()
was added as a static method. Note that if you need to use custom settings, you need to pass them in the settings
parameter.Instance properties
toLoadCount
. It's the counter of the elements that haven't been lazyloaded yet.DOM
data-was-processed
attribute, that was added to mark lazy DOM elements as "already managed". If you were manually handling that attribute to obtain some goal, this is a potentially breaking change. You should now refer to the data-ll-status
instead.data-ll-status
attribute, which is now used to mark the status of a lazy DOM element. The values it can take are: observing
(not loaded yet), loading
(loading started), loaded
(load completed), error
(an error has occured), native
(similar to observing
, but managed by native lazy loading).Love this project? 😍 Buy me a coffee!
Changelog
13.0.1
Changelog
13.0.0
dist/lazyload.esm.js
as dist/lazyload.esm.min.js
, so now you can effortlessly use it with an ES module import
statement when using type="module"
dist/lazyload.iife.min.js
now weights only 2.03 KB GZippedcallback_set
callback that was deprecated since version 11 in favour of callback_reveal
_extends
function inside LazyLoad's scope (it was global before)Changelog
12.5.1
Restored IE 11 compatibility, which was broken since 12.2.0. See #414. Thanks to @ninosaurus for reporting.
Changelog
12.5.0
The once-private _loadingCount
property is now public and renamed to loadingCount
. This property contains the number of images that are currently downloading from the network, limitedly to the ones managed by an instance of LazyLoad. This is particularly useful to understand whether or not is safe to destroy an instance of LazyLoad. See implementation in the destroy demo.
Thanks to @wzhscript and @eugene-stativka.
Changelog
12.3.0
Callbacks now pass more arguments!
callback_enter
, callback_exit
now pass:
IntersectionObserverEntry
that triggered the enter/exit eventcallback_load
, callback_error
, callback_reveal
now pass
callback_finish
now passes:
The README file has been updated accordingly.
Changelog
12.2.0
Released new feature "retry when back online". Now if your users lose the internet connection causing errors on images loading, this script tries and loads those images again when the connection is restored.
Changelog
12.1.1
Solved a bug with Internet Explorer 11 and the W3C polyfill, as reported in #383.