🚩 Finally Native lazy-loading for the web was introduced. I recommend you to use loading
attribute instead.
lazyload-image
HTMLImageElement extension for lazy loading. Images will be loaded when they are shown.
Install
Install lazyload-image
via npm.
$ npm install lazyload-image
Usage
Import LazyloadImage
and register it.
; customElements;
Modify your <img>
elements such as following.
Fallback
If a browser does not support customElements.define()
, images will be loaded as usual.