如何阻止Google广告拖慢网站?Chrome性能分析相关技术咨询
Hey there, let's work through your issues one by one:
1. Where does show_ads_impl.js come from?
Even though you removed AdSense and only have the Google AdWords remarketing code with the async tag, this file is actually a dependency loaded by Google Ads-related scripts — including AdWords remarketing. The remarketing snippet you're using likely pulls in this file in the background to handle ad-related functionality.
To confirm the exact initiator, open Chrome DevTools' Network tab, filter for show_ads_impl.js, and check the "Initiator" column. This will show you which script is triggering its load.
2. How to use <link rel="preload"> properly
The performance tool's suggestion to use preload is to help the browser fetch this critical script earlier, reducing load times. Here's how to implement it:
Placement
Add the preload link inside your HTML <head> tag — this ensures the browser sees it early and prioritizes the resource.
Example Code
First, grab the full URL of show_ads_impl.js from the Network tab (the exact URL might look like https://pagead2.googlesyndication.com/pagead/js/show_ads_impl.js). Then add this line:
<link rel="preload" href="https://pagead2.googlesyndication.com/pagead/js/show_ads_impl.js" as="script" crossorigin>
- The
as="script"tells the browser it's loading a script resource. - The
crossoriginattribute is required here because the script is hosted on a different domain (Google's servers), which ensures proper preloading of cross-origin resources.
Important Note
Preload only fetches the resource — it won't execute it automatically. Since your AdWords remarketing script already loads this file, preload will just cache it ahead of time, so when the remarketing script requests it, it's already ready to go.
Additional Optimization Tips
- Double-check your AdWords remarketing code to ensure you're using the latest version. Google occasionally updates these snippets to improve performance.
- If the remarketing script isn't critical for above-the-fold content, consider delaying its load until after the page has fully rendered. You can do this by wrapping it in a
DOMContentLoadedevent listener or using a lazy-loading approach. - Use Chrome DevTools' Performance tab to run another audit after implementing preload — this will let you verify if the issue is resolved.
内容的提问来源于stack exchange,提问作者Genadinik

