Blazy is a fast, SEO friendly and small but still feature-rich lazy load script. It was originally build for lazy loading images but it can also lazy load any element with a source attribute like iframes, unity games, html5 videos, scripts etc.
Blazy comes with a bunch of features like serving retina images for retina screens, multi-serve images depending on screensize and error handling. For a list of all features and more details you can visit the blog post. Blazy works in all modern browsers including IE7+.
var bLazy = new Blazy({ // Options });
<img class="b-lazy" data-src="image.jpg" />
CSS: .b-lazy { opacity:0; transform: scale(3); transition: all 500ms; } .b-loaded { opacity:1; transform: scale(1); }
<img class="b-lazy" src="low-res-image.jpg" data-src="image.jpg" />
<img class="b-lazy" sizes="100vw" data-srcset="large.jpg 1024w, medium.jpg 640w, small.jpg 320w" data-src="medium.jpg" />
<picture> <source media="(min-width: 650px)" data-srcset="image-650.jpg" /> <source media="(min-width: 465px)" data-srcset="image-465.jpg" /> <img class="b-lazy" data-src="default.jpg" /> </picture>
<img class="b-lazy" data-src="image.jpg|retina-image.jpg" />
<div class="b-lazy" data-src="image.jpg"></div>
var blazy = new Blazy({ container: '.container' });
var blazy = new Blazy({ container: '.container' });
<iframe class="b-lazy" data-src="https://www.youtube.com/embed/uKtjVQ5IJOQ" frameborder="0" allowfullscreen> </iframe>
<video class="b-lazy" data-src="video.mp4" controls></video>
<video class="b-lazy" controls> <source data-src="video.mp4" type="video/mp4"> <source data-src="video.webm" type="video/webm"> Your browser doesn't support HTML5 video tag. </video>
Check the console log
<script class="b-lazy" data-src="script.js" async></script>