How To Add LazyLoad Google Adsense in Blogger ?

How To Add LazyLoad Google Adsense in Blogger

Hello Everyone, on this occasion I will share How to Add LazyLoad Google Adsense in Blogger. Adsense is certainly no stranger to all bloggers. Adsense is an alternative way for a publisher to earn money on a blog. On the other hand adsanse js also affects the loading of the blog, which reduces the loading speed of the blog a bit.

For those of you who have just got Adsense. Have implemented the script provided by Adsense on my blog. You will definitely see that the speed of your blog is less than before.

So I will suggest in this post how to set up the right ad unit and use Lazy Load Adsense to speed up blog loading.

What is Lazyload Adsense ?

Lazy load is a technique to delay the Adsense JS on the Adsense website to be asynchronous, which means that once the top content is fully loaded, Adsense JS will not load.

Lazy Load Adsense is useful to speed up blog loading by temporarily delaying the loading of Adsense JS. And moreover when the page is scrolled by the user the adsense js will be loaded.

How To Add LazyLoad Google Adsense in Blogger :-

Step 1 :-First of All Go To Blogger.Com And Login Your Blogger Account.
Step 2 :- Then Click on Theme Menu.
Step 3 :- Then Click on Edit Html.
Step 4 :- Then find </body> and then paste the lazy loaded Google adnsense code given.
<script>/*<![CDATA[*/
var lazyadsense2 = false;
window.addEventListener("scroll", function(){
if ((document.documentElement.scrollTop != 0 && lazyadsense2 === false) || (document.body.scrollTop != 0 && lazyadsense2 === false)) {
(function() { var ad = document.createElement('script'); ad.setAttribute('data-ad-client','ca-pub-123456789xxxxxxx'); ad.async = true; ad.src = 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js'; var sc = document.getElementsByTagName('script')[0]; sc.parentNode.insertBefore(ad, sc); })();
lazyadsense2 = true;
  }
}, true);
/*]]>*/
</script>

Note :- Change Your Ca Pub Id.

Step 5 :- Then Don't Forget to Click on Save Theme.

Note :- If your template still includes this script, remove this script. <script async="" src= "https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"><script>

Recommended Adsense Ad Unit Writing :-

One of the reasons for slow blog loading is the frequent writing of Adsense scripts (adsbygoogle.js). So every time you add an ad unit you don't need to rewrite adsense script, write correct ad unit like below example

<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-123456789xxxxxxx"
     data-ad-slot="12345xxxxx"
     data-ad-format="auto"
     data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>

Not Recommended Adsense Ad Unit Writing :-

<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- link -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-880246522xxxxxxx"
     data-ad-slot="69271xxxxx"
     data-ad-format="auto"
     data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>

Conclusion :-

In this post I have told you about all How To Add LazyLoad Google Adsense in Blogger. So how did you like this post, you can tell by commenting.

Refrence:
Www.SmartTechMukesh.Online

Read Also :