If you’ve placed a Google AdSense ad on your WordPress site by copying the ad code directly into a post or widget, each individual ad block loads its own copy of the AdSense script — meaning if you have several ad placements on one page, you’re loading the same script multiple times over. Loading it once and letting all your ad slots share it cuts down on requests and speeds up the page.
Step 1: Find the shared script
At the top of your AdSense ad code, you’ll find a script tag that’s identical across every ad unit you’ve created. For asynchronous ads, it looks like this:
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
Step 2: Move it into your theme header
In your WordPress admin, go to Appearance > Theme Editor and open your active theme’s header file (header.php). Back up the file first — a mistake here can break your site’s layout or take it down. Paste the script tag somewhere between the <head> and </head> tags, then save.
Step 3: Remove the duplicate copies
Go back to each individual ad placement on your site and delete this same script line from each one — leave the rest of each ad unit’s code (the <ins class="adsbygoogle"> block) in place, just remove the now-redundant loader script.
Result
Save everything, and if you’re running a caching plugin, give the caches time to refresh. Your pages will now make one request for the AdSense script instead of one per ad, which reduces total requests and helps your page load a little faster — particularly noticeable on pages with several ad placements.
Resources
Gear We Recommend
A few general tech accessories worth having alongside this.
Browse our General Tech Accessories picks on AmazonAs an Amazon Associate, TechyGeeksHome earns from qualifying purchases.
Discover more from TechyGeeksHome
Subscribe to get the latest posts sent to your email.