#2 · Primary category: Web Performance & Predictive Loading

vanilla-lazyload

hacktoberfest iframes images intersectionobserver lazy-loading lazy-sizes lazyload lazyload-iframes lazyload-images lazyload-script lazyload-videos picture picture-tag responsive-images srcset srcset-sizes vanilla-javascript vanilla-js videos webp

A lightweight vanilla JavaScript lazy loading library that defers images, videos, iframes, and scripts until they enter the viewport, using IntersectionObserver and supporting responsive images.

Project last updated:06/22/26

GitHub Stars

7.9K

Forks

673

Contributors

47

License

MIT

Why we included this project

Pages heavy on images, embedded video, or third-party iframes slow down noticeably on first load, and vanilla-lazyload is a battle-tested way to fix that without pulling in a framework. It's a tiny script, around 2.4 kB, that defers anything below the fold until it actually scrolls into view, using the IntersectionObserver API. The real value is in the details it handles for you: responsive images through srcset and sizes, the picture tag with WebP fallbacks, background images with HiDPI variants, animated SVGs, and video posters. You swap real attributes for data- attributes in your markup and instantiate it with a few lines of JavaScript. It also keeps a fallback for browsers without IntersectionObserver, which makes it a safe pick for sites that still serve older browsers.

Articles for this project

No articles for this project yet.

To suggest a topic or contribute an article, contact us.

Related projects in this category