🔔 Alert..!! Get 2 Month Free Cloud Hosting With $200 Bonus From Digital Ocean ACTIVATE DEAL

A dead simple, ultra-light (1kb), and cross-browser jQuery image lazy load plugin that dynamically loads and replaces the placeholder with original image when the img tag is scrolled into view.

lazy-load

Documentation

jquery.lazy

A tiny JQuery plugin to enable image lazy loading.

How to use jquery.lazy

Step 1: Include jquery.lazy.js after jquery

<script src="jquery-3.3.1.min.js"></script> <script src="jquery.lazy.js"></script> 

Step 2: Your image elements should be like this:

<img lazy src="placeholder.png" data-src="image1.png" /> <img lazy src="placeholder.png" data-src="image2.png" /> <img lazy src="placeholder.png" data-src="image3.png" /> <img lazy src="placeholder.png" data-src="image4.png" /> <img lazy src="placeholder.png" data-src="image5.png" /> <!-- More images -->

Step 3 ( Alternative ): If your images don't have the lazy attribute but a class or an id:

<img class="some-random-class" src="placeholder.png" data-src="image1.png" /> <img class="some-random-class" src="placeholder.png" data-src="image2.png" /> <img class="some-random-class" src="placeholder.png" data-src="image3.png" /> <img class="some-random-class" src="placeholder.png" data-src="image4.png" /> <img class="some-random-class" src="placeholder.png" data-src="image5.png" /> <!-- More images -->
$('img.some-random-class').lazy();

You May Also Like