How to lazy Load Images on Website or blog

How to lazy Load Images on Website or blog

Updated on 17 May
Lazy loading images helps you to decrease your website load time and the functionality of this lazy loading jQuery plugin as it will search for the images and load that images on request for example it will not load all the images on page load it will load the images as you scroll down to that image. If you are having too much images on your website then you have to use this plugin because this will help you a lot.

So if you want to install this lazy loading images functionality on your blogger blog follow the steps which are provided below and do it as it is said.

How to lazy Load Images on Website or blog


Steps to Add Lazy Loading Functionality:

  1. Go To Blogger Dashboard
  2. Then Go to Theme / Template
  3. Click Edit HTML Button
  4. Now search for </head>
  5. To Search anything in blogger Press Ctrl + F and type or paste the term to search in search bar.

    How to lazy Load Images on Website or blog

  6. Now copy the code provided below and paste it just above the tag which we have founded in step 4.
  7. <script>
    //<![CDATA[
    // Lazy Load
    (function(a){a.fn.lazyload=function(b){var c={threshold:0,failurelimit:0,event:"scroll",effect:"show",container:window};if(b){a.extend(c,b)}var d=this;if("scroll"==c.event){a(c.container).bind("scroll",function(b){var e=0;d.each(function(){if(a.abovethetop(this,c)||a.leftofbegin(this,c)){}else if(!a.belowthefold(this,c)&&!a.rightoffold(this,c)){a(this).trigger("appear")}else{if(e++>c.failurelimit){return false}}});var f=a.grep(d,function(a){return!a.loaded});d=a(f)})}this.each(function(){var b=this;if(undefined==a(b).attr("original")){a(b).attr("original",a(b).attr("src"))}if("scroll"!=c.event||undefined==a(b).attr("src")||c.placeholder==a(b).attr("src")||a.abovethetop(b,c)||a.leftofbegin(b,c)||a.belowthefold(b,c)||a.rightoffold(b,c)){if(c.placeholder){a(b).attr("src",c.placeholder)}else{a(b).removeAttr("src")}b.loaded=false}else{b.loaded=true}a(b).one("appear",function(){if(!this.loaded){a("<img />").bind("load",function(){a(b).hide().attr("src",a(b).attr("original"))[c.effect](c.effectspeed);b.loaded=true}).attr("src",a(b).attr("original"))}});if("scroll"!=c.event){a(b).bind(c.event,function(c){if(!b.loaded){a(b).trigger("appear")}})}});a(c.container).trigger(c.event);return this};a.belowthefold=function(b,c){if(c.container===undefined||c.container===window){var d=a(window).height()+a(window).scrollTop()}else{var d=a(c.container).offset().top+a(c.container).height()}return d<=a(b).offset().top-c.threshold};a.rightoffold=function(b,c){if(c.container===undefined||c.container===window){var d=a(window).width()+a(window).scrollLeft()}else{var d=a(c.container).offset().left+a(c.container).width()}return d<=a(b).offset().left-c.threshold};a.abovethetop=function(b,c){if(c.container===undefined||c.container===window){var d=a(window).scrollTop()}else{var d=a(c.container).offset().top}return d>=a(b).offset().top+c.threshold+a(b).height()};a.leftofbegin=function(b,c){if(c.container===undefined||c.container===window){var d=a(window).scrollLeft()}else{var d=a(c.container).offset().left}return d>=a(b).offset().left+c.threshold+a(b).width()};a.extend(a.expr[":"],{"below-the-fold":"$.belowthefold(a, {threshold : 0, container: window})","above-the-fold":"!$.belowthefold(a, {threshold : 0, container: window})","right-of-fold":"$.rightoffold(a, {threshold : 0, container: window})","left-of-fold":"!$.rightoffold(a, {threshold : 0, container:window})"})})(jQuery);$(function(){$("img").lazyload({placeholder:"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEVDlvcf4k5KJRU1pKSBQWD4eUPSZX9JE8m3mh7mF4F6MTX5ZT0Jgf3-15UIb1w0ceVps9zjDvTrq3aziu3oxaV2Q33cEYWcJ0htExI7a_JOcnT1iK8yFjVGOdd65xf0fP-n6oQJzgvGa8/",effect:"fadeIn",threshold:"0",effectTime:"2000"})});
    //]]>
    </script>
    In the above just replace the highlighted image URL with your own image.
  8. Save Theme / Template.

0 comments for How to lazy Load Images on Website or blog

Cancel