WordPress Speedup – Change the way you add Google Adsense Ads
Google Adsense is a great way of earning some cash by placing a few adverts on your WordPress blog. However, if you create an advert in your Google Adsense console and just copy and paste it straight into your WordPress site, you are loading a separate script each time for each advert. So, would it not be better to just load the script once and then have all your adverts be served by the one loaded script?
Well, you can do it and it is very simple to do by following the few basic steps below.
First of all, you need to identity the script that will need to be loaded just the once. You will find this at the top of your ad code. If you are using asynchronous ads then the script will look something like this:
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
Take this script and then go into your WordPress Administrator Console. Then browse your way to Themes -> Editor. You then need to edit your Theme Header (header.php) file. Once you are in the editor, paste the script in between the <head> and </head> part. This will then load this part of the script from the header on page load.
All you need to do then is to delete this same code from each advert that you have on your website.
Save everything and then give it some time for your caches to catch up (if you are using them – which you should be!) and you will find that your website is making much less requests and in turn will load quicker speeding your website up!
We would love to hear your feedback on this guide and whether it has helped you or if you have any further suggestions or questions – just leave us a comment below.