How to Lazy Load Adsense Ads in Blogger
icon-search
How to Lazy Load Adsense Ads in Blogger

How to Lazy Load Adsense Ads in Blogger

How to Lazy Load Adsense Ads

Making your website fast is a technique to increase your website traffic and also increase your rankings on Google.

You should have heard about lazy loading images but today I am going to tell you how you can lazy load AdSense ads to make your website load faster.

Without this script when your website loads it takes too long because it has to fetch data from Google AdSense but after this your website will load faster and AdSense ads will be loaded on event and that event is scroll.

Steps To Follow:

  1. Go to Blogger.com
  2. Go to Theme Section
  3. Click on Edit HTML
  4. Now copy the code provided below.
  5. 
    // LazyLoad AdS
    Var lazyadsense=!1;window.addEventListener("scroll",function(){(0!=document.documentElement.scrollTop&&!1===lazyadsense||0!=document.body.scrollTop&&!1===lazyadsense)&&(!function(){var e=document.createElement("script");e.type="text/javascript",e.async=!0,e.src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js";var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(e,a)}(),lazyadsense=!0)},!0);
    
  6. Search for </body>
  7. Pess CTRL+F and paste your search term and hit enter.
  8. Paste code above this tag.
  9. Now search for </head> and paste the code below above this tag.
  10. <!--Adsense Integration-->
    <script>
      (adsbygoogle = window.adsbygoogle || []).push({
        google_ad_client: "Your-Client-ID-Here",
        enable_page_level_ads: true
      });
    </script>
    <!--/AdSense Integration-->
  11. Save Theme

Replace Your-Client-ID-Here with your client id like ca-pub-1928361826382617.

Now where you want to put your AdSense ads you have to add AdSense AD Code don't use AdSense AD widget because if you add AdSense AD widget in blogger then this script will not work because adsbygoogle.js script will be automatically loaded.

This was simple tutorial I think this helped you a lot and if it did make sure to subscribe to the newsletters of this blog.
Disqus Codes

No comments

Notifications

Disqus Logo