Lazy loading images

I recently found this JQuery plugin that saved my life. I was authoring a Help page that had lots of images in it. Total page load was 5.6Mb.

I had ideas on how to deal with this by hiding content and creating a table of contents that loaded content when it was requested. It was probably going to take some time to put together though. Then I found this plugin – http://www.appelsiini.net/projects/lazyload.

Essentially, it loads a placeholder image in your page instead of the actual image file. You can customise this placeholder and make it look as nice as you want but be sure to keep it as small as possible to ensure page load is slick. Then this script listens on the scroll event and when it finds a lazy image element, it loads the resource from file. I have watched my network resource utilisation in Chrome as the script executes and it’s amazing to watch. The page first loads (313Kb in total) and then as I scroll down the page, the total download ticks over … and over … and over.

Here are a code snippet. It is a JQuery plugin, so make sure you load JQ before trying to use it.

<script type="text/javascript" src="jquery.js"></script><script type="text/javascript" src="jquery.lazyload.js"></script><script type="text/javascript">// <![CDATA[
	$( function() {
		$("img.lazy").lazyload();
	});
// ]]></script><img class="lazy" alt="" src="img/grey.gif" width="640" height="480" data-original="img/example.jpg" /> <img class="lazy" alt="" src="img/grey.gif" width="640" height="480" data-original="img/example.jpg" /> <img class="lazy" alt="" src="img/grey.gif" width="640" height="480" data-original="img/example.jpg" /> <img class="lazy" alt="" src="img/grey.gif" width="640" height="480" data-original="img/example.jpg" />

So we have lots of images of class lazy with a src of “img/grey.jpg”. This is the image that will be loaded for all images. Then, as you scroll down the page, the src reference is replaced with the data-original value and the image is loaded. This continues as you scroll up and down the page.

Til next time …


16 Comments

  • Sheree says:

    Outstanding post however , I was wondering if you could write a litte more on this topic?
    I’d be very thankful if you could elaborate a little bit further.

    Thanks!

    My web-site :: ray ban sunglasses stores (Sheree)

  • Luca says:

    Thanks designed for sharing such a pleasant
    thought, piece of writing is good, thats why i have read it
    completely

  • Collin says:

    Seo is the means to go in seeing to it your web site acquires picked up by
    Google, Yahoo as well as Bing.

  • Michel says:

    One search engine optimization practice that will benefit particular web pages on your internet
    site is interlinking.

  • Generally, if there is a particular high rated
    website on your website, you can link from that web page to a lower rated websites to enhance the reduced placed page’s ranking.
    As a whole, it is likewise good technique to see to it that every websites
    on your site has a link to it from elsewhere on the website.

  • uscity.net says:

    It aids you place very on online search engine as well as if anybody it going to acquire your item, click your
    advertisements or even offer you a donation they absolutely need to manage to discover your site in the first place.
    Most people do exceed the first search results page and also hardly ever past the 2nd web page.
    Do on your own a support and make your webpage more available to potential viewers with SEO.

  • They go to restaurants, hotels, like special cuisine, spend time in pubs and bars to eat and drink.

    ca where you can print your own vouchers and redeem them at your favorite
    restaurant. These guides show reviews about the restaurants which are given by people.
    Peachtree Street North Restaurants – Follow the same
    directions above, but turn left on Peachtree Street for:.

    Delhi being the capital city of India and also an important tourist
    destination offers wide range of restaurants to
    cater to the different classes of visitors. You have nothing to lose, and a
    good deal to acquire, by supplying it a attempt. From MARTA, go all the way to the
    top of station on the escalators or elevators to Arts Center Way.
    The style of the restaurant should match the skills of the hired
    chef.

  • Apertura de Cajas Fuertes en Barna Si necesita un cerrajero
    en Barcelona, llámenos y saldrá ganando.

  • When no choice exists, no competition exists, and the poorest
    performing school systems have no incentive to better themselves – their
    students are going to keep coming and they are going to continue to
    receive funding for those students because their parents have
    no other option. When I explained the process to them they were willing
    to take the voucher. 30am, we went straight home
    for a well earned sleep.

  • Asking questions are genuinely good thing if you are not understanding anything fully, however this article offers good understanding yet.

  • Thanks for finally writing about >Lazy loading images – Web Design With .Net <Liked it!

  • you are in point of fact a excellent webmaster. The web site
    loading pace is incredible. It kind of feels that
    you’re doing any distinctive trick. In addition, The contents are masterpiece.

    you have done a magnificent job in this subject!

  • There is certainy a great deal to know about this subject.
    I love all oof the points you’ve made.

  • It is not my first time to go to see this website, i am browsing this site
    dailly and take nice information from here everyday.

  • Eloisa says:

    Se ha dicho que el habla de los afásicos de Broca es
    telegráfica, ya que tan sólo se conservan los nombres.

  • Are able to make your own work for you, not the other way out there.

    My daughter stood among that number for a time,
    and her daughter stands included in this now.
    I had no idea what ever became of his forerunners.

Leave a Reply

Your email address will not be published. Required fields are marked *