Friday, May 9, 2014

Lazy Loading – Decrease loading time of Page

What is Lazy Loading?

Lazy loading is a design pattern commonly used in programming to defer initialization of an object until the point at which it is needed. It can contribute to efficiency in the program’s operation if properly and appropriately used. The opposite of lazy loading is eager loading
Lazy Loading is use for Images, contents, blocks etc., It means when page or blocks gets scroll then and then only content or images will be displayed. its a jQuery Plugin.

How to Integrate with our application?

There are three simple steps and get done. For now I am going to explain lazy loading with images,
Add lazy load javascript and css(jquery.lazyload.js and lazyload.css) on head tag, JS and CSS are available on market so, get it from it and add to head tag

The basic usage of Lazy is very easy. First of all you need to add a ‘data-src’ attribute to those images you want to load when image block will get displayed and insert the image path you want to load over Lazy: like below,
<img class=”lazyload” data-original=”actual source of image” src=”blank or loading image”/>

Add simple line of code to call lazy load class at footer, like below,

<script type=”text/javascript”>jQuery(“img.lazyload”).lazyload();</script>
 With This script site performance can be increase because now a days people are adding big image on websites so developer needs to resize to display on web, and also page will take time to load images also, so this is one good way to optimize site performance.

Hope you like this post and it will be useful for all of you.

1 comment:


  1. This is realy a Nice blog post read on of my blogs It is really helpful article please read it too my blog PINTEREST BUTTON NOT WORKING. you can visits our websites or toll free no +1-866-558-4555. solve your problem fastly.

    ReplyDelete