Need to speed up the super slow Google ad script?
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>
Hello,
Is it possible to implement this code on Google ad manager??
If no, then please share code for Google ad manager.
Thanks
Follow info at the link below to delay any script.
https://www.wpfixit.com/delay-script-load-in-wordpress/
Does not work for me at all.
Just shows the script on the page instead of the ads
There must be a typo in the code. Please double check.
You can also delay it using the tip at https://www.wpfixit.com/delay-script-load-in-wordpress/
Hello WP, I would like to use the code to delay adsense on my site but it looks confusing to me
What part are you stuck on?
Hello there..
This idea looks great and i don’t find it anywhere on the Internet. Is this same as delay javascript feature from wp rocket?
Google makes a hell lot of changes to their algorithms and policies. Is it safe to use in 2022?
Hello
This is for sure safe to use. It does not change the script. It just delays it a moment before loading.
How about ads coming from Ezoic, Mediavine or any other media network?
No, this is specific to Google Ads only.
This is a very good way of delaying the ad.
Does it mean that if I have multiple ads on the same page, I could use only one scripts for multiple ?
Possible to do so.
Yes it is possible for sure.
Is it safe to use such code? Google doesn’t usually allow code modification except the ones mention on their policy page. Is this modification allowed?
Yes it is and works great.
Hi, is this code ok for the latest version of Auto-ads?
Yes.