This is a forked branch from tuupola
For the changes I have made scroll to the ChangeLog.
Lazy Load delays loading of images in long web pages. Images outside of viewport wont be loaded before user scrolls to them. This is opposite of image preloading.
Using Lazy Load on long web pages containing many large images makes the page load faster. Browser will be in ready state after loading visible images. In some cases it can also help to reduce server load.
Lazy Load is inspired by YUI ImageLoader Utility by Matt Mlinac.
Lazy Load depends on jQuery. Include them both in end of your HTML code:
<script src="jquery.js" type="text/javascript"></script> <script src="jquery.lazyload.js" type="text/javascript"></script>
You must alter your HTML code. URL of the real image must be put into data-original attribute. It is good idea to give Lazy Loaded image a specific class. This way you can easily control which images plugin is binded to. Note that you should have width and height attributes in your image tag.
<img class="lazy" data-original="img/example.jpg" width="640" height="480">
then in your code do:
$("img.lazy").lazyload();
This causes all images of class lazy to be lazy loaded.
- The following changes will make more sense when used in a Single page web application
- Added a Preload function : this allows to preload the specific number of images which are outside the viewport. And will be introduced to viewport next. This was done to improve the User Experience. As with lazy loading it was very broken.
- Added a trigger_lazyload() : funation which triggers that lazyload. It could be used in places of collapse views. on Clicks. Or pagination (inside views).
- Added bypass_lazyload : If it is set to true it will bypass the lazyloading and update all the with approporiate data when called. Should be used in case of complex cases when lazyloading does not function as expected.
- JQUERY LAZYLOADING FOR MOBILE: “jquery.mobile.lalyload.js” this is more optimized and effecient version of mobile web apps.
*Includes events like “tap”, “scrollstop” etc
- Improved Bower support
- Bower support (mrzmyr)
- Fix iOS5 detection for iPhone (Berik Visschens)
- Use .attr() instead of .data() since jQuery caches values when using latter. Fixes #37, #144 and #101 (Lorenz an Mey).
- Do not add data:uri placeholder for non image elements.
- Add support for CSS background images.
- Make external placeholder image optional by providing default 1×1 grey image as data uri (Dave Mc Nicoll)
- Fix bug #47 and #71. Mobile Safari window height changes when scrolling. (Girvan)
- Revert #70 because it causes more problem than solves. Only proper fix in Webkit browsers is to set width and height either as attributes or in CSS. Without width and height Webkit sees image as size 0×0 and causes jQuery to assume they are not visible. Fixes bugs #99, #98 and #88.
- Fix bug #118. Scrollstop event was not compatible with jQuery 1.9.×.
- Fix bug #120. Sometimes event.originalEvent was not defined under iOS. (David G. Durand)
- Support for jQuery plugin repository
- Proper fix for #48. If image did not have width and height set Webkit browsers needed initial scroll for images to display. (@sc-aboudreau)
- Workaround for bug #30 IOS5 Safari did not load images when navigating with back button.
- Fix bug #48. In some cases initial scroll was needed for images to load. (Nick George)
- Fix bug #42. Reset internal failure counter when image is found. Makes counter logic more intuitive. (Josep del Rio)
- Fix bug #52. Fix :in-viewport convenience method. (Jonathan Palardy)
- Allow different elements to use different containers. (Rob Walch)
- Fix bug #18. Document was always scrolled to top issue on IE 7 and Chrome 17 if using jQuery 1.6 or older. (Ross Allen)
- General code speedup (Valentin Zwick)
- Optimized viewport selectors. Around 25% speed increase compared to 1.6.0.
- Add data_attribute parameter. Allows custom naming of original data attribute. (Bryan Chow)
- Track window resize event. (Simon Baynes)
- Add appear event. This function is called when image appears to viewport but before it is loaded.
- Add load event. This function is called when image is loaded. (Nick Larson)
- Renamed effectspeed parameter to effect_speed. Old version will still works couple of versions. This parameter was previously undocumented.
- Fix failure_limit bug #19. (Brandon)
- Rename original attribute to data-original to be HTML5 friendly.
- Remove all code regarding placeholder and automatically removing src attribute. It does not work with modern browsers. Must use data-original attribute instead.
- Add support for James Padolseys scrollstop event. Use when you have hundreds of images.
- Add skip_invisible parameter. When true plugin will skip invisible images. (Valentin Zwick)
- Renamed failurelimit parameter to failure_limit. Old version will still work couple of versions.
- Support for removing the src attribute already in HTML. This is not a drop in solution but gives additional speed for those who need it. (Jeremy Pollock)
- When scrolling down quickly do not load the images above the top. (Bart Bruil)
- Support for scrolling within a container.
- Fixed IE not loading images.