If You Want top backlinks or free guest posting on our blog Lets do it Join in Google News

How to install lazyload adsense with auto ads

3 Read time

How to install lazyload adsense with auto ads



A blogger is certainly no stranger to adsanse, adsanse is an alternative way for a publisher to make money on a blog, on the other hand adsanse js also affects the loading of the blog so it's heavy.

For those of you who have just received Adsense and have implemented the script provided by Adsense, of course you will be surprised when you check your blog's speed decreases by 40%.

therefore on this occasion I will give tips on how to install the correct ad unit and use lazyload adsense to speed up blog loading.

What is Lazyload Adsense?

lazyload adsanse is a technique to delay the loading of adsanse js on the website to be asynchronous, meaning that once the top content is fully loaded, the adsanse js will not load.

lazyload adsense is useful for speeding up blog loading by temporarily delaying the loading of adsense js. and furthermore the adsense js will be loaded when the page is scrolled by the user.

How to Install Lazyload Adsense

please copy the code below and place it above the </body> code if you don't find it it may have been parsed so that it becomes <!--</body>--></body> and change the part that I have marked with your ca-pub code and click save

<script>
    //<![CDATA[
    var lazyadsense = false; window.addEventListener("scroll", function(){ if ((document.documentElement.scrollTop != 0 && lazyadsense === false) || (document.body.scrollTop != 0 && lazyadsense === false)) { (function() { var ad = document.createElement('script'); var crs = document.createAttribute('crossorigin'); crs.value = 'anonymous'; ad.setAttributeNode(crs);  ad.async = true; ad.src = 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-880246522xxxxxxx'; var sc = document.getElementsByTagName('head')[0]; sc.parentNode.insertBefore(ad, sc); })(); lazyadsense = true; } }, true)
    //]]>
    </script>

if your template still has this script
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-880246522xxxxxxx" crossorigin="anonymous"></script> please removed.

Recommended Adsense Ad Unit Writing

one of the causes of slow loading blogs is due to the repeated writing of the adsense script (adsbygoogle.js). so every time you add an ad unit you don't need to rewrite the adsense script, write the correct ad unit like the example below


    <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>

Writing Adsense Ad Units Not Recommended


    <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-880246522xxxxxxx" crossorigin="anonymous"></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>

so many ways to install lazyload adsense with auto ads hopefully it's useful

Thanks for reading: How to install lazyload adsense with auto ads,Dont Forget to Book Mark The Blooger-store.com

About the Author

Hi Greetings! thanks for reaching here, We are so delighted to welcome you on board. Your intelligence and energy make you an asset to your family and love ones.

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It Look like there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.