The Lazy plugin for jQuery load specified images after the page load itself and speed up your loading time through this. Images outside of the visible area will only get loaded when the user scrolls to them. This will not only increase the page loading speed, it will even decrease your traffic.
Lazy will work with a wide range of browsers and support jQuery versions for years backwards. You can pick any version since jQuery 1.3.0 or greater.
- nevşehir escort
- trabzon escort
- kastamonu escort
- gönen escort
- çorlu escort
- samsun escort
- balıkesir escort
- muğla escort
- rize escort
- erzincan escort
1. INCLUDE JS FILES
you need to add a 'data-src' attribute to those images you want to load delayed and insert the image path you want to load over Lazy
<img class="lazy" data-src="path_to/image.jpg" src="" />
Overview of all settings you can use to configure Lazy and change its behavior:
|bind||strong||load||If set to 'load' Lazy starts working directly after page load. If you want to use Lazy on own events set it to 'event'.|
|threshold||integer||500||Amount of pixels below the viewport, in which all images gets loaded before the user sees them.|
|fallbackHeight||integer||2000||If the plugin could not determine a viewport height, it will use this fallback height.|
|visibleOnly||boolean||true||Determine if only visible images should be load.|
|appendScroll||jQuery||window||An element to listen on for scroll events, usefull when images are stored in a container.|
|delay||integer||-1||If you want to load all images at once after pageload, then you can specify a delay time in milliseconds.|
|combined||boolean||false||With this parameter, Lazy will combine the event driven and delayed image loading.|
|attribute||string||data-src||Name of the image tag attribute, where the image path is stored.|
|removeAttribute||boolean||true||Determine if the attribute should be removed from the image tag after loading.|
|effect||string||show||Function name of the effect you want to use to show the loaded images, like 'show' or 'fadeIn'.|
|effectTime||integer||0||Time in milliseconds the effect should use to view the image.|
|enableThrottle||boolean||true||Throttle down the loading calls on scrolling event.|
|throttle||integer||250||Time in milliseconds the throttle will use to limit the loading calls.|
|beforeLoad||object||null||Callback function, which will be called before the image gets loaded. Has current element as parameter.|
|onLoad||object||null||Callback function, which will be called wile the image is loading. Has an image object as parameter.|
|afterLoad||object||null||Callback function, which will be called after the image was loaded. Has current element as parameter.|
|onError||object||null||Callback function, which will be called if the image could not be loaded. Has an image object as parameter.|
|onFinishedAll||object||null||Callback function, which will be called after all images was loaded or returned an error. This callback has no parameter.|
By default, Lazy will load images on scroll or resize event, when an images enters the threshold/viewport. But there is also an option to load all images after a given delay time. You can set the time in milliseconds with the 'delay' parameter.
Lazy gives you the option to use callback functions, before, on and after loading images. And if the imange to load was not found, there is even a error callback. You can use them to create a better and more dynamic user experience or for further events.
The before and after load callback will have the current element as parameter. Because Lazy can even handle non-img tags, the on and error callbacks will always have an image object as parameter.
So the throttle will limit those calls in a given time. In this timespawn only one call will be handled and all others will be ignored.
By default this option is activated and will work in background. You will not notice it. There are some parameters to change the timespawn, for faster or slower handling, or deactivate the throttle: