Early accessCodeGecko is opening to a first group of teams.Join the waitlist

How much do third-party scripts slow down your site?

Analytics, chat and ads look free when you paste them in. Here’s how they hurt LCP, INP and CLS, how to measure the real cost, and what to fix.

Nour8 min read ·
Third-party scripts

The cost of one more tag.

Someone asks for a chat widget. Marketing wants a new analytics tool. Sales wants a heatmap, legal wants a cookie banner, and the A/B testing tool needs “just one line in the head”. Each one is a snippet you paste in, and each one looks free.

It isn’t. You don’t pay when you paste it in. You pay later, in your real visitors’ numbers, a few milliseconds at a time. Here’s where that cost comes from, why your usual tests miss it, and how to measure what one tag actually costs you.

The short answer

It depends on the tag, and you can’t know it in advance. A small, well-behaved script loaded with async can cost almost nothing. A chat widget, an A/B testing tool or an ad slot can make the page show later, make taps feel slow and make the layout jump.

The only reliable way to find out is to measure it on real visits: compare the release that added the tag with the release before it, page by page and device by device, at the 75th percentile.

Every tag looks free when you paste it in. The bill arrives in your real users’ numbers.

What counts as third party

A third-party script is any script served from someone else’s domain. If your site is shop.com, a file from cdn.shop.com is still yours. A file from a chat vendor, an analytics company or an ad network is not.

The usual suspects:

  • Analytics and heatmap tools.
  • Tag managers, which exist to load more tags.
  • A/B testing and personalisation tools.
  • Chat and support widgets.
  • Ads and ad-tracking pixels.
  • Video and map embeds, like YouTube or Google Maps.
  • Cookie and consent banners.
  • Fonts, reviews, social buttons and payment widgets.

The catch is that the snippet you paste is rarely the whole thing. It’s often a small loader that downloads a bigger script, which then loads more scripts, styles, images and fonts from more domains. One line in your code can become dozens of requests, and the vendor can change what those requests do at any time without you shipping anything.

How they hurt each metric

Third-party scripts touch most of the Core Web Vitals, each in its own way.

  1. 01LCP gets later. A script in the head without async or defer stops the browser from drawing the page until it has downloaded and run. Every new domain also needs its own connection, and their bytes compete for bandwidth with your hero image. On a phone on 4G, that adds up fast.
  2. 02INP gets slower. Third-party code runs on the same main thread as yours. If a widget is busy setting itself up, or a tracking script runs on every click, a tap has to wait for it to finish. These long tasks are one of the most common reasons for a slow Interaction to Next Paint.
  3. 03CLS goes up. Banners, ads, embeds and review widgets are often injected after the page has drawn, with no space reserved for them. Everything below jumps down, sometimes just as someone goes to tap a button.
  4. 04TTFB mostly doesn’t change. Time to First Byte is about how fast your server answers, and that happens before any script runs. The exception is tags that run on the server or at the edge before the page is sent.

INP is usually where it hurts most, and it’s the hardest to see. We went through what makes clicks slow, and how to find the slow one, in What is a good INP score? And how to fix a slow one.

Why Lighthouse undersells it

Run Lighthouse after adding a tag and the score may barely move. That doesn’t mean the tag is cheap. A lab test simply doesn’t see most of its cost.

  • It runs on a fast machine. Even with throttling turned on, it’s not the mid-range Android many of your visitors use, where the same script takes far longer to run.
  • Nobody accepted the cookie banner. Many tags only fire after consent. In the lab, consent is never given, so a lot of what real visitors load never loads.
  • Nobody is logged in. Personalisation, chat and support tools often do more for signed-in visitors and returning customers.
  • It’s one page load. It doesn’t click, scroll, open the chat or move to a second page, which is when many widgets wake up.

We wrote about the wider gap between lab tests and real visits in Your Lighthouse score is green. Why are your Core Web Vitals failing?

Measuring the real cost

A tag usually goes live in a release, so measure it the same way you’d check any deploy. Compare real visits to the release that added (or removed) the tag with real visits to the release before it. Look at one page on one kind of device at a time, using the p75, and only call it a change when both sides have enough visits and the difference beats everyday noise. We explain the method in Did my deploy slow down my site? How to know for sure.

If the tag is added through a tag manager instead of a deploy, note the time it went live and compare the days before and after for the same pages. It’s less clean, but it’s far better than guessing.

Here’s what a release that added a chat widget might look like:

LCP got 220ms slower, past its 115ms bar, because the widget’s script and its connection now compete with the main image. INP jumped by 75ms, since the widget sets itself up while people are already tapping. CLS didn’t move: the chat bubble floats in a corner, so nothing gets pushed down. The two third-party rows show where the time went.

CodeGecko measures this on every release. Next to the verdicts, it shows third-party size, the compressed bytes each visit downloaded from other domains, and third-party blocking, the part of the long frames spent running other domains’ scripts. You also get the top third-party domains by size and by blocking, with any domain the previous release never reported marked as new. These numbers explain a change. They never decide the verdict on their own, since their cost already shows up in the metrics that do.

Fixes that work

  1. 01Audit and delete. List every tag on the site and ask who still uses it. Old analytics tools, finished experiments and pixels for campaigns that ended are common, and the fastest script is the one you remove.
  2. 02Load with async or defer. A script in the head without either one blocks the page from drawing. Most tags work fine with async, and anything that doesn’t need to run early can use defer.
  3. 03Load later, or on interaction. Chat, video and maps rarely need to load before someone wants them. Show a lightweight facade, like a static chat button or a YouTube thumbnail with a play icon, and load the real thing on click. For the rest, wait until the page has finished loading.
  4. 04Reserve space for injected UI. Give ad slots, embeds, banners and review widgets a fixed size in your CSS before they arrive, or show cookie banners as an overlay that doesn’t push the page down.
  5. 05Preconnect only to what matters. A preconnect hint for the one or two third-party domains you need early can save time. Preconnecting to ten domains wastes connections the hero image needed.
  6. 06Self-host when the license allows. Fonts and some small libraries can be served from your own domain. That removes a connection, and you control when the file changes.
  7. 07Check again after every release. Vendors update their scripts without telling you, and tags get added through tag managers without a code review. Look at third-party cost after each deploy so a new one doesn’t slip by.

Start with the audit. Removing a tag nobody uses is a five-minute change, and it’s the only fix that brings the cost all the way to zero.

A checklist

Third-party cost creeps up the same way INP does. One tag at a time, each one small, until a page that passed is in the yellow. Catching it release by release is much easier than finding it weeks later in Google’s 28-day report.

That’s what we built CodeGecko for. It collects Core Web Vitals from real visits, groups them by release, and tells you after each deploy whether any page and device got slower, with third-party size and blocking next to the verdict. The docs list everything we measure, and the demo shows a release report.

  • Treat every new tag as a change to measure, not a free extra.
  • Know which scripts come from other domains, and what they load in turn.
  • Don’t trust Lighthouse to show the cost. It skips consent, logins and clicks.
  • Compare the release that added a tag with the one before it, at the 75th percentile, per page and device.
  • Delete what nobody uses, load the rest later, and reserve space for anything injected.
  • Check third-party cost after every release, because vendors change their scripts too.
NourBuilding CodeGecko

Senior frontend engineer, night-shift gamer, weekend photographer, and the human who taught a gecko to watch your deploys.

Get in early.

We’re letting teams in a few at a time. Join the waitlist and we’ll email you once, when your spot opens.

Go deeper

Keep reading