Third-party scripts: how tags and widgets hurt Core Web Vitals
Analytics, chat widgets, ads, and tag managers often cause slow INP and layout shifts. Here is how to audit third-party scripts and cut the cost.
Most slow pages are not slow because of the code you wrote. They are slow because of the code you pasted in. Analytics, chat widgets, ad tags, A/B testing tools, and cookie managers all run on your page, and you do not control how they behave. This guide shows how to find the ones that cost you the most and what to do about each.
Why third-party scripts matter for search
Core Web Vitals are measured on real visits, and a third-party script runs in the same browser tab as your content. It shares the same main thread. If a tag spends 300 milliseconds running a long task, your page cannot respond to a tap during that time. That hurts Interaction to Next Paint (INP).
Scripts also hurt the other two metrics. A late-loading banner or ad slot can push content down and raise Cumulative Layout Shift (CLS). A heavy tag that competes for bandwidth can delay your hero image and slow Largest Contentful Paint (LCP).
Page experience is one signal among many, and Google has said great content can still rank with weak vitals. Treat this as a user problem first and a ranking tiebreaker second. A page that feels stuck loses visitors before any algorithm does.
Find the expensive scripts
Do not guess. Measure. You need two views: what each script costs in a lab test, and whether real users feel it.
- Run the page in Lighthouse and open the third-party usage audit. It lists each origin with its transfer size and main-thread blocking time.
- Open the Performance panel in Chrome DevTools, record a page load, and sort the main thread by long tasks. Click a task to see which script owns it.
- Check your field data in Search Console or the Chrome UX Report. If INP is poor on real visits, look at which interactions are slow, not just the load.
- List every tag inside your tag manager. Old campaign pixels and abandoned tests are common, and nobody remembers adding them.
Expect a short list to account for most of the cost. A couple of tags usually do the damage, and the rest are small.
Fixes that work
Remove what you do not use
The fastest script is the one you delete. Audit every tag against a simple question: who looks at this data, and when did they last do so? If the answer is nobody, remove it. Do this every quarter, because tags pile up quietly.
Load scripts later
Add the async or defer attribute to scripts that do not need to run before the page renders. Analytics rarely needs to block anything. Chat widgets can wait until the visitor scrolls or clicks. Loading on interaction is a common pattern, but test it. A widget that appears late can still cause a layout shift if you do not reserve its space.
Reserve space for anything that loads in
Ad slots, embeds, and consent banners should have a fixed height in your CSS before they load. Set the container size so the page does not jump when the content arrives. This is the most reliable fix for CLS caused by third parties.
Replace heavy embeds with a facade
A video embed or map can pull in hundreds of kilobytes. A facade shows a lightweight image first and loads the real embed only when someone clicks. It looks the same and costs far less up front.
Be careful with tag managers
A tag manager is not slow by itself. It makes it easy for anyone on the team to add a script without a performance review. Set a rule: every new tag needs an owner and a check against your vitals before it goes live.
What you cannot fix, and what to do about it
Some scripts are out of your hands. You cannot edit an ad network's code. You can still limit the damage. Cap the number of ad slots, lazy load the ones below the fold, and compare vendors on performance when you renew a contract. Ask vendors for their own performance numbers, but verify them on your pages.
Moving a script to a web worker is an option that some tools support, and it keeps work off the main thread. It is still an uneven practice. Some scripts break when moved, so test the result before you roll it out.
Also keep in mind that AI crawlers mostly read your HTML and do not run your tags. Third-party scripts affect human visitors far more than they affect citations. Your fixes pay off in real user experience.
Your next step
Open your top landing page in Lighthouse today and read the third-party usage list. Pick the one script with the highest blocking time. Decide whether to remove it, delay it, or replace it, make that one change, and re-measure in a week. Repeat until the list is short and every script has an owner.