
Photo Guilherme Jófili
After neglecting the code for a while I was finally able to release new version of Lazy Load plugin. Changes are not dramatic but there is one important thing. New browsers load image even if you remove the src attribute with JavaScript. Because of this you must alter your html code. Put placeholder image into src attribute of your img tag. Real image url should be stored data-original attribute.
<img data-original=“img/example.jpg” src=“img/grey.gif”>
All code regarding the old behavior where you could just include plugin code in your page and it would automagically lazyload your images was removed.
There are cases when you have invisible images. For example when using plugin in together with a large filterable list of items that can have their visibility state changed dynamically. To improve performance hidden images are now ignored by default. If you want to load hidden images set the new skip_invisible parameter to false.
$("img.lazy").lazyload({
skip_invisible : false
});
Support for James Padolseys scrollstop event was added. Use it when you have hundreds of images on page. Check the demo page to see it in action. I have extracted the code from James’ webpage and put it into separate file.
<script src="jquery.scrollstop.js" type="text/javascript" charset="utf-8"></script>
$("img").lazyload({
event: "scrollstop"
});
Parameter failurelimit was renamed to failure_limit. Old version will work for couple of versions. I cannot seem to be able to decide on my own coding standards…
Latest source or minified. Plugin has been tested with Safari 5.1, Firefox 3.6, Firefox 7.0, Firefox 8.0 on OSX and Firefox 3.0, Chrome 14 and IE 8 on Windows and Safari 5.1 on iOS 5 both iPhone and iPad.
Tagged with: Javascript Jquery Lazy load