WANT US TO SPEED UP YOUR SITE?
WANT US TO SPEED UP YOUR SITE?

SUPER SLOW Google Ad Script on WordPress – This is How You Fix It

written by WP Fix It

October 10, 2017

Oh yes the infamous SUPER SLOW Google Ad Script on WordPress. This is a speed sucker and will surely slow down the full load time of your entire page. Well we have come up with a way to delay the load of this script in order to start loading it 5 seconds after the page is fully loaded. This is a very useful tip for websites as the ads can fade in after the page is fully loaded and not interfere with the main goal of content being visible. This is NINJA stuff right here!!!

So no need to make this post super long winded. Let us just share the code with you below. The 2 items you must change that in the code that are unique to your Google Ad account are UNIQUE_ACCOUNT# and UNIQUE_AD#. Please let us know if you have any issues with this.
 
 
STANDARD GOOGLE AD SCRIPT:

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-UNIQUE_ACCOUNT#"
data-ad-slot="UNIQUE_AD#"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

 
5 SECOND DELAYED CODE GOOGLE AD SCRIPT:

<ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-UNIQUE_ACCOUNT#" 
data-ad-slot="UNIQUE_AD#"></ins>

<script type='text/javascript'>
(function() {
var done = false;
var script = document.createElement('script');
script.async = true;
script.type = 'text/javascript';
script.src = '//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js';

var createScript = setTimeout(
function(){
document.getElementsByTagName('HEAD').item(0).appendChild(script);
}, 5000
);

script.onreadystatechange = script.onload = function(e) {
if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) {
(adsbygoogle = window.adsbygoogle || []).push({});
}
};
})();
</script>
26 Shares
WordPress Speed Up Service

You May Also Like…

2 Comments

  1. bucksy

    Hi, is this code ok for the latest version of Auto-ads?

    Reply

Submit a Comment

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

LET US GET STARTED RIGHT AWAY

READY TO GET YOUR SITE FIXED