Daily Latest Tech Update

How To Speed Up Website Loading with Adsense Enabled

  • Share

Website speed depends on many aspects from back end and front end part. If you have enable ads in your site, it will affect your website loading speed. In this blog, I will discuss how to speed up website loading with Adsense enabled. Even Adsense use asynchronous loading to prevent blocking render when loading Adsense library, in fact it takes sometimes and affect user experience when visiting our website.

One of hack we can use is using lazyload method. We will load Adsense JS library in onscroll function. Change this short line that provide by Google and replace it with following modification code.

<script async src="//"></script>

Replace it with:

<script type='text/javascript'>//<![CDATA[// Lazy Load AdSensevar 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="";var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(e,a)}(),lazyadsense=!0)},!0);//]]></script>

Place your ads, in bottom of your content, so when user load your page, and scroll page, it will load Adsense JS library, and your ads will be showed.

  • Share

Leave a Reply

Your email address will not be published. Required fields are marked *