{"id":5316,"date":"2024-10-30T02:41:41","date_gmt":"2024-10-30T09:41:41","guid":{"rendered":"https:\/\/www.ultimatewb.com\/blog\/?p=5316"},"modified":"2025-05-25T22:52:22","modified_gmt":"2025-05-26T05:52:22","slug":"reduce-pagespeed-impact-of-google-adsense","status":"publish","type":"post","link":"https:\/\/www.ultimatewb.com\/blog\/5316\/reduce-pagespeed-impact-of-google-adsense\/","title":{"rendered":"How to Lazy Load Google Adsense Ads for a Fast Website"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.ultimatewb.com\/blog\/wp-content\/uploads\/pagespeed-insights-seo-ultimatewb-services.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"651\" src=\"https:\/\/www.ultimatewb.com\/blog\/wp-content\/uploads\/pagespeed-insights-seo-ultimatewb-services-1024x651.jpg\" alt=\"\" class=\"wp-image-5318\" srcset=\"https:\/\/www.ultimatewb.com\/blog\/wp-content\/uploads\/pagespeed-insights-seo-ultimatewb-services-1024x651.jpg 1024w, https:\/\/www.ultimatewb.com\/blog\/wp-content\/uploads\/pagespeed-insights-seo-ultimatewb-services-300x191.jpg 300w, https:\/\/www.ultimatewb.com\/blog\/wp-content\/uploads\/pagespeed-insights-seo-ultimatewb-services-768x488.jpg 768w, https:\/\/www.ultimatewb.com\/blog\/wp-content\/uploads\/pagespeed-insights-seo-ultimatewb-services.jpg 1158w\" sizes=\"(max-width: 600px) 100vw, (max-width: 1200px) 75vw, 1200px\" \/><\/a><figcaption class=\"wp-element-caption\">This is an example of the Performance boost we have gotten after implementing this Lazy Loading Ads trick.<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>&#8220;Integrating Google Adsense Ads takes the PageSpeed Insights Mobile Performance Score from 98 to 85 because of the &#8220;Total Blocking Time&#8221; &#8211; Is there any way to avoid this?&#8221;<\/strong><\/h2>\n\n\n\n<p>Yes! Thanks for your <em><a href=\"https:\/\/www.ultimatewb.com\/ask-david\">\u201cAsk David!\u201d<\/a><\/em> question. Reducing the performance impact of Google Adsense ads can be challenging since they often load additional resources and scripts that affect page speed. However, we have found that doing Lazy Loading for ads brings the Mobile Performance Score back in the green, to the upper 90&#8217;s, if not 100.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to Lazy Load Ads<\/strong><\/h2>\n\n\n\n<p>You can lazy load ads by using Intersection Observer to lazy-load ads only when they\u2019re about to enter the viewport. This can improve the initial page load and overall performance scores by only loading ads as users scroll down.<\/p>\n\n\n\n<p>Here&#8217;s the code:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.ultimatewb.com\/blog\/wp-content\/uploads\/ultimatewb-adds-app-integreate-google-adsense-ads.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"709\" src=\"https:\/\/www.ultimatewb.com\/blog\/wp-content\/uploads\/ultimatewb-adds-app-integreate-google-adsense-ads-1024x709.jpg\" alt=\"UltimateWB Ad(d)s App\" class=\"wp-image-5317\" srcset=\"https:\/\/www.ultimatewb.com\/blog\/wp-content\/uploads\/ultimatewb-adds-app-integreate-google-adsense-ads-1024x709.jpg 1024w, https:\/\/www.ultimatewb.com\/blog\/wp-content\/uploads\/ultimatewb-adds-app-integreate-google-adsense-ads-300x208.jpg 300w, https:\/\/www.ultimatewb.com\/blog\/wp-content\/uploads\/ultimatewb-adds-app-integreate-google-adsense-ads-768x531.jpg 768w, https:\/\/www.ultimatewb.com\/blog\/wp-content\/uploads\/ultimatewb-adds-app-integreate-google-adsense-ads.jpg 1214w\" sizes=\"(max-width: 600px) 100vw, (max-width: 1200px) 75vw, 1200px\" \/><\/a><\/figure>\n\n\n\n<p>Using UltimateWB website builder, copy\/paste the following code in the Ad(d)s app, for &#8220;Right before end body tag&#8221;:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;script&gt;document.addEventListener(\"DOMContentLoaded\", function() {\n  const ads = document.querySelectorAll('.adsbygoogle');\n  const observer = new IntersectionObserver((entries, observer) =&gt; {\n    entries.forEach(entry =&gt; {\n      if (entry.isIntersecting) {\n        const script = document.createElement('script');\n        script.src = \"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\";\n        script.defer = true;\n        document.body.appendChild(script);\n        script.onload = function() {\n          (adsbygoogle = window.adsbygoogle || &#91;]).push({});\n        };\n        observer.unobserve(entry.target);\n      }\n    });\n  });\n  ads.forEach(ad =&gt; observer.observe(ad));\n});&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<p>And you can add your Google Adsense code to a new Ad(d) that you create, and then copy\/paste the generated Placeholder Text to the List Pages &gt; Add \/ Edit Page, where you want it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;div class=\"adsbygoogle-container\"&gt;\n    &lt;ins class=\"adsbygoogle\"\n         style=\"display:block\"\n         data-ad-client=\"&#91;your info]\"\n         data-ad-slot=\"&#91;your info]\"\n         data-ad-format=\"auto\"&gt;&lt;\/ins&gt;\n&lt;\/div&gt;  <\/code><\/pre>\n\n\n\n<p>By using the Ad(d)s app, you can use the same Placeholder Text for the Google Adsense ad to easily place multiple ads on various sections of your website.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Additional Tips<\/strong><\/h2>\n\n\n\n<p><strong>Optimize Ad Placement and Density<\/strong>: Reducing the number of ad slots per page or moving them further down can improve the initial load time and boost the page\u2019s performance score.<\/p>\n\n\n\n<p>We haven&#8217;t found this necessary, but some have suggested:<\/p>\n\n\n\n<p><strong>Limit Ad Formats and Styles<\/strong>: Certain ad formats, like rich media or video, tend to load more resources and impact performance more than static or simpler formats. Using lighter ad formats or setting ad slots to fixed sizes (instead of <code>data-ad-format=\"auto\"<\/code>) may reduce resource load.<\/p>\n\n\n\n<p>Having PageSpeed Insights scores in the green can help with your website <a href=\"https:\/\/www.ultimatewb.com\/blog\/?s=seo\">SEO<\/a> and <a href=\"https:\/\/www.ultimatewb.com\/blog\/?s=search+engine+ranking\">search engine ranking<\/a>, so it is well worth it implementing this trick when you want to integrate ads. It doesn&#8217;t have to be one or the other :-)<\/p>\n\n\n\n<p>Are you ready to design &amp; build your own website? Learn more about&nbsp;<a href=\"https:\/\/www.ultimatewb.com\/\">UltimateWB<\/a>! We also offer&nbsp;<a href=\"https:\/\/www.ultimatewb.com\/web-design-packages\">web design packages<\/a>&nbsp;if you would like your website designed and built for you.<\/p>\n\n\n\n<p><em>Got a techy\/website question? Whether it\u2019s about UltimateWB or another website builder, web hosting, or other aspects of websites, just send in your question in the&nbsp;<a href=\"https:\/\/www.ultimatewb.com\/ask-david\">\u201cAsk David!\u201d form<\/a>. We will email you when the answer is posted on the UltimateWB \u201cAsk David!\u201d section.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;Integrating Google Adsense Ads takes the PageSpeed Insights Mobile Performance Score from 98 to 85 because of the &#8220;Total Blocking Time&#8221; &#8211; Is there any way to avoid this?&#8221; Yes! Thanks for your \u201cAsk David!\u201d question. Reducing the performance impact &hellip; <a href=\"https:\/\/www.ultimatewb.com\/blog\/5316\/reduce-pagespeed-impact-of-google-adsense\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1034,4],"tags":[2130,383,382,3464,3465,738,3028,2864,12,11,3463],"class_list":["post-5316","post","type-post","status-publish","format-standard","hentry","category-ask-david","category-search-engine-optimization-seo","tag-content-lazy-loading","tag-google-ads","tag-google-adsense","tag-lazy-loading","tag-lazy-loading-ads","tag-mobile-friendly","tag-pagespeed-insights","tag-performance","tag-search-engine-ranking","tag-seo","tag-total-blocking-time"],"_links":{"self":[{"href":"https:\/\/www.ultimatewb.com\/blog\/wp-json\/wp\/v2\/posts\/5316"}],"collection":[{"href":"https:\/\/www.ultimatewb.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ultimatewb.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ultimatewb.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ultimatewb.com\/blog\/wp-json\/wp\/v2\/comments?post=5316"}],"version-history":[{"count":5,"href":"https:\/\/www.ultimatewb.com\/blog\/wp-json\/wp\/v2\/posts\/5316\/revisions"}],"predecessor-version":[{"id":6044,"href":"https:\/\/www.ultimatewb.com\/blog\/wp-json\/wp\/v2\/posts\/5316\/revisions\/6044"}],"wp:attachment":[{"href":"https:\/\/www.ultimatewb.com\/blog\/wp-json\/wp\/v2\/media?parent=5316"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ultimatewb.com\/blog\/wp-json\/wp\/v2\/categories?post=5316"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ultimatewb.com\/blog\/wp-json\/wp\/v2\/tags?post=5316"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}