Lazy load your images. Tested on IE7+, Firefox, Chrome, iOS. Supports handling of images that are placed in the DOM after ajax requests or images that are made visible after the page loads.
-
Include
lazyload.js
-
Add
data-src
to each of your<img>
tags. Optionally add a placeholder src, and thelazy-load
class, however it is not necessary but can be used to animate the images.
<img class="lazy-load" data-src="lazy.jpg" src="blank.gif" />
<noscript><img src="lazy.jpg" /></noscript>
-
Call
lazy.init()
after images are ready in the DOM. This method adds all images with thedata-src
attribute to a cache andlazy.load()
's them if the image.is(':visible')
-
If images are initially not visible, you can call
lazy.load()
when they become visiible.