How to resolve the issue when adding Google Adsense ad code causes your website to slow down and results in low page speed scores. A solution to help your website load faster and achieve higher scores on PageSpeed Insights.
Why does website load Google AdSense super slow?
When you add Google AdSense code to your website, the default snippet will inevitably reduce page load speed and lower scores when tested with tools like GTmetrix and Google PageSpeed Insights. The reason is that, during page loading, the code sends a request to download and display Ads from its application source. This increases the original size, consequently slowing down the website, whether it’s Google Analytics or Google AdSense.
Optimizing Page Load Speed When Using Google Adsense Ads
Adding Google Adsense ad code can slow down page load times and result in low speed scores. However, there’s a simple way to mitigate this issue by loading the Adsense code only when the user interacts with the website.
Instead of loading the Adsense code immediately when the page starts loading, we can utilize the scroll event to delay the load until the user scrolls or clicks on the page.
Adsense ads, or any other ad network’s code, can slow down websites and cause very low speed test scores. Similar to the previous instructions for Google Analytics, we can use the scroll
event to load the Adsense code. This method ensures that ads are displayed as soon as the user scrolls, effectively handling both mobile and desktop experiences.
The optimized script
below has been edited to ensure 100% of Google’s speed points are not lost, and the ads are displayed as soon as scrolling occurs, so it won’t affect your impressions or revenue. Most importantly, it won’t slow down your website with Google Adsense ads.
The above code will be inserted into the head
tag of the website. Then, to display ads with Google Adsense, copy the generated code and insert it into your website in your preferred method. It should look like this:
Note: Replace ca-pub-xxxxx with your actual Adsense code!
The methods outlined above optimize and enhance the code for third-party applications like Adsense when adding them to your website, ensuring they don’t reduce page load performance. Additionally, these techniques will help you achieve maximum scores on speed test tools like Gtmetrix and Google PageSpeed Insights. As a result, you no longer have to worry about Google Adsense slowing down your website or low Pagespeed scores.