Share:

AdSense Lazy Load  

  RSS
Paul Paul
(@paul)
Active Member

Just above the < / body> code, we add the JS code below.

 

<script type='text/javascript'>
//<![CDATA[
// İlkay Gürler - www.ilkaygurler.com
// Lazy Load AdSense
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);
//]]>
</script>

Then we delete all adsense js codes from our blog template already attached to our JS code, you can contact us via the source link for your comments and questions thanks.

Quote
Posted : 07/01/2020 1:53 pm
Paul Paul
(@paul)
Active Member

You can also use this as an alternative.

A code is added in each ad unit. All contain the following JS code

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

ReplyQuote
Posted : 07/01/2020 1:54 pm
Share:

Please Login or Register