Lozad
Advanced Lazy Loader using Intersection Observer API
lozad.js is a light-weight library to lazy load elements using JavaScript.
It is written with an aim to lazy load images, ads, videos or any other element using the recently added Intersection Observer API with tremendous performance benefits.
Installation
lozad.js is just 569 bytes minified & gzipped.
- Bower:
bower install lozad
- NPM:
npm install lozad
- Download zip.
Note: lozad.js supports AMD and commonJS module pattern out of the box.
Usage
new Lozad(); // lazy loads images with selector class as 'lozad'
with custom options:
new Lozad({
selectorClass: 'lozad', // for identification of images to lazy load
rootMargin: '10px 0px', // syntax similar to that of CSS Margin
threshold: 0.1 // ratio of image convergence
})
Reference:
Browser Support
Available in latest browsers. If browser support is not available, then make use of this polyfill.
Contributing
Interested in contributing features and fixes?
Read more on contributing.
Changelog
See the Changelog
License
Copyright (c) 2017 Apoorv Saxena, https://apoorv.pro
Licensed under the MIT license.