Adsense Ads Lazy Load - Lazy Load AdSense Ads
In today's article we are going to share with you the script of Adsense lazy load. How to Download Why Use Adsense Lazy load things have pros and cons.
What is Lazyloading Adsense?
Adsense Lazy load is a simple Java script code that you can use to increase the speed of your website.
One of the problems everyone sees is that the website takes a long time to load. And if you don't increase the load speed of your website then your website will not be ranked by Google so it is very important to increase the load speed of your website and for that you need to use a script called adsense lezy load script.
For example, users come to read your website page and scroll back after reading the first few lines. So, here those images and videos which load at the bottom of the webpage are loaded without any reason because the user does not scroll the page. So, by lazy loading images, videos and ads at the bottom, you can increase the speed a bit more.
Lazyload Adsense In Blogger
To Lazyload Adsense in Blogger, follow the below steps carefully.
Step 01: Go to Blogger dashboard and click on Theme section.
Step 02: Now take a backup of your theme and click on Edit HTML.
Step 03: Remove all previous Adsense code from your blogger theme.
Step 04: Now copy the below code and replace it with your own Adsense publisher ID.
Lazy Load for Blogger
<script type='text/javascript'> //<![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-xxxxxxxxxxxxxxxx'); 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>
Step 05: Now save your Adsense code and your lazyload AdSense in added to Blogger website.
Download
Click Here To Download
Now all of your Adsense ads will load after the page load and you will see a significant boost in your page loading speed.
Lazy Load Adsense Wordpress
To Lazyload Adsense in Wordpress, follow the below steps carefully.
Step 01: Go to Wordpress dashboard and click on Theme section.
Step 02: Now take a backup of your theme and click on Edit HTML.
Step 03: Remove all previous Adsense code from your Wordpress theme.
All you need to follow below two Steps
Remove below script from all existing ad units.
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
Step 04: Now copy the below code and replace it with your own Adsense publisher ID.
Now it will appear like this
<ins class="adsbygoogle"style="display:inline-block;width:728px;height:90px"data-ad-client="ca-pub-xxxxxxxxxxxxxxxx"data-ad-slot="1234567890"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script>
After then, add below JavaScript code in your Theme Footer, possibly just before the body tag.
Hint: Noptimize tag is present to make compatible with Autoptimize. It will prevent aggregating AdSense lazy loader inline JS.
Lazy Load for Wordpress
<!--noptimize--> <script type="text/javascript"> function downloadJSAtOnload() { var element = document.createElement("script"); element.src = "https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"; document.body.appendChild(element); } if (window.addEventListener) window.addEventListener("load", downloadJSAtOnload, false); else if (window.attachEvent) window.attachEvent("onload", downloadJSAtOnload); else window.onload = downloadJSAtOnload; </script> <!--/noptimize-->
Step 05: Now save your Adsense code and your lazyload AdSense in added to Wordpress website.
Now all of your Adsense ads will load after the page load and you will see a significant boost in your page loading speed.
lazy loading advantages and disadvantages
There are some advantages and some disadvantages of using adsense lazy loding script because everything has its plus point and negative point. First we will discuss the advantages. Using adsense lazy load will increase your website speed thus increasing traffic to your website. This is because using adsense lazy load script gives most of the advantages. Disadvantage is that your ads may have fewer clicks and some important things may open lazily.