In this article you will learn about lazy loading plug-in from jQuery. It first loads your web page then request is sent to load the images of that page.
By using Lazy load plug-in you can decrease time for loading the page and also it can increase the performance of the website.
It can help in loading long web pages including large images and your page will load faster. browser will show the page after loading all the images.
To implement it in your application, follow these steps:
1. Include these js files into the head of your html page
<script src="jquery.js" type="text/javascript"></script>// latest version of jQuery core file
<script src="jquery.lazyload.js" type="text/javascript"></script>
2. After including files you have to set loader image path in src of img tag in your html file and set actual path of the image into attribute named data-original.
<img class="lazy-load" src="img/loader.gif" alt="" width="640" height="480" data-original="images/example.jpg" />
3. Now you need to write this javascript code. It will trigger event based on the class added into image.
$("img.lazy-load").lazyload({
event : "click"
});
or you can also directly call lazy load function like this:
$(".lazy-load").lazyload();
0 Comment(s)