Do Third-Party Scripts Slow Down Your Site? What Core Web Vitals Show

Some third-party scripts cost you nothing measurable and some cost you a second of load time. Here is how to tell which is which, and the loading method that keeps a widget off your critical path.

Third-party scripts slow down your site only when they block rendering or occupy the main thread, and how you load them matters more than how many you have. An async or defer script of a few dozen kilobytes usually leaves your Core Web Vitals untouched; a synchronous script in the <head>, or a 500 KB embed that runs on every page, will show up in all three metrics.

Key takeaways

  • A third-party script hurts you through three channels: render-blocking, main-thread work, and layout shifts. Size alone predicts very little.
  • async and defer both stop a script from blocking the parser; defer also waits for the HTML to finish, so it is the safer default.
  • Loading after the load event, or behind a facade, removes a script from the page-load path entirely, at the cost of the feature appearing later.
  • Measure the same URL in PageSpeed Insights twice, with and without the script, and compare LCP, INP and total blocking time, not the single score.
  • The SealReply chat widget is an async script of about 38 KB that doesn't block your page from showing, adds no fonts or iframes, and has a checkbox to load it after the page instead.

A browser window drawing its page content while a small script file arrives later on a separate lane

What does a third-party script actually cost your page?

A third-party script is JavaScript your page loads from somebody else's domain: analytics, chat, ads, fonts, maps, consent banners, A/B testing. It charges you in three separate currencies, and a given script may be expensive in one and free in the other two.

  • Render-blocking. A plain <script src="..."> in the <head> stops HTML parsing until the file has downloaded and run. On a slow connection that is a blank screen for as long as the round trip takes.
  • Main-thread work. Once downloaded, the script has to be parsed, compiled and executed. This is the cost async and defer do not remove — they change when the work happens, not whether it happens.
  • Layout shifts. Anything that inserts a banner, a bar or a badge into the normal page flow after content has drawn pushes the rest down, and that is counted against you.

Two scripts of identical size can therefore behave completely differently. A 40 KB async widget that renders into its own isolated layer is close to free; a 40 KB synchronous tag manager in the <head> that then pulls in five more files is not.

Which Core Web Vitals do third-party scripts break?

Each of the three Core Web Vitals has its own failure mode, and knowing which one a script threatens tells you what to do about it. Google's thresholds, measured at the 75th percentile of real page loads, are published in web.dev's Core Web Vitals reference:

Metric Good How a third-party script breaks it What fixes it
LCP (Largest Contentful Paint) ≤ 2.5 s A render-blocking script in the <head> delays the paint of your hero image or headline async / defer, or load after the page
INP (Interaction to Next Paint) ≤ 200 ms Long tasks from script execution make the first tap or click feel stuck Delay execution, split work, or drop the script
CLS (Cumulative Layout Shift) ≤ 0.1 An injected banner or bar shifts content that was already drawn Reserve the space, or use a fixed/overlay position

A chat widget, a cookie banner and an analytics tag each sit in a different row of that table, which is why "we have 12 third-party scripts" tells you nothing on its own.

async, defer, after load, or a facade: which one?

There are four practical ways to load a third-party script, and they trade freshness against page-load cost. The behaviour of async and defer is specified in MDN's reference for the script element.

Four stacked timeline lanes comparing blocking, parallel, after load and placeholder loading

Method When it runs Blocks rendering? Good for
No attribute Immediately, pausing the parser Yes Almost nothing; only code the first paint depends on
async As soon as it arrives, in any order No, but can interrupt parsing briefly Independent scripts you want up early: chat, analytics
defer After the HTML is parsed, in document order No Scripts that touch the DOM or depend on each other
After the load event Once everything else has finished No Anything a visitor won't need in the first seconds
Facade On hover or click No Heavy embeds: video players, maps, large chat UIs

A facade is a lightweight placeholder that looks like the real embed and swaps itself for the real thing when someone interacts with it. Chrome's Lighthouse documentation on lazy-loading third parties with facades gives the clearest example: a YouTube facade weighs about 3 KB, while the player it replaces weighs about 540 KB, and most visitors never click play.

Loading after the page is one line

You don't need a library to delay a script. Wrap the insert in a load listener and the page is fully drawn before the request even starts:

<script>
  window.addEventListener("load", function () {
    var s = document.createElement("script");
    s.src = "https://cdn.example.com/widget.js";
    s.async = true;
    document.body.appendChild(s);
  });
</script>

The honest trade-off: a facade and a load-event script are strictly better for your score and strictly worse for the feature. A visitor who lands on your pricing page with a question and finds no chat button for four seconds may just leave.

How do you measure a third-party script's real cost?

Measure the same URL twice, with the script and without it, and compare the metrics rather than the score. Google's PageSpeed Insights documentation explains the split you'll see on the report: the top section is field data from real Chrome users over a trailing 28-day window, and the bottom is a single lab run on a simulated phone. Only the lab half reacts to a change you made five minutes ago.

A magnifying glass over a performance report with three gauges, beside a scale weighing script files

  1. Pick one page that matters commercially — a product page, a pricing page, a landing page — not your homepage.
  2. Run it through PageSpeed Insights and write down LCP, INP (or TBT in the lab run), CLS and total JavaScript size.
  3. Remove or comment out the one script you're testing, deploy, and run the identical URL again.
  4. Compare. A difference under about 50 ms on a metric is noise; run each version three times before you believe a small number.
  5. Open the lab report's "Reduce the impact of third-party code" and "Avoid long main-thread tasks" entries — they attribute time to specific domains, so you learn which third party to argue with.

Careful with "delay all JavaScript" switches

Speed plugins and optimisation services often offer to postpone every script until a visitor scrolls, moves the mouse or taps. That reliably improves your lab score and reliably breaks anything the visitor needed before that first interaction — including the chat button they were looking for. Exclude the scripts you actually want working, or delay them explicitly to the load event instead.

In a single-page app, measure after a client-side route change as well as on first load. Scripts added through a framework's loader behave differently across navigations, which is why adding live chat to Next.js needs its own strategy choice rather than a pasted <script> tag.

What to do when a script is genuinely too slow

Once you know which script costs you, there are only five moves, roughly in order of how much they're worth:

  • Remove it. The cheapest optimisation is the tag nobody has looked at in a year. Audit what's on the page; dead analytics and abandoned A/B tools are extremely common.
  • Load it later. Move it to defer, the load event, or a facade, as above.
  • Load it on fewer pages. A checkout-survey script does not belong on blog posts. Most platforms, including live chat on WordPress, can restrict a snippet to certain page types.
  • Self-host it, carefully. This removes a DNS lookup and a TLS handshake, but you also take on updating the file, and many vendors' terms forbid it.
  • Replace it with something smaller. Two tools that do the same job can differ tenfold in weight, and weight is one of the few things you can check before signing up.

How does the SealReply chat widget load?

The embed code is a single async script tag, and the file it points to is a loader of about half a kilobyte. The loader does two things: it opens the connection to our API immediately with a preconnect hint, and it inserts the real widget, which is cached under a content-hashed filename. The widget is about 38 KB of asynchronous JavaScript, it doesn't block your page from showing, and it adds no fonts, no iframes and no stylesheets to your page — the interface lives in a Shadow DOM, so your CSS and ours never meet.

Here is what we measured on our own build (production bundle, cross-origin CDN, cold cache, median of 10 runs on a simulated phone at 4× CPU slowdown and Fast 3G):

Metric, with widget minus without Result
First Contentful Paint no change (within noise)
Total Blocking Time 0 ms
Main-thread work +87 ms
load event +784 ms
Chat button visible 2.0 s after the page opened

That load event number is the honest part: the page's first paint and interactivity don't move, but the browser's "everything finished" event waits for the script, so on a slow first visit it lands about 0.8 seconds later. Cached visits cost close to nothing.

If every millisecond counts

On the install step in the console there's a checkbox called Load the chat after the page. Tick it and you get the load-event version of the snippet instead: your content draws first and the chat button follows a moment later. The trade-off is that calls to SealReply methods before the page has loaded won't do anything.

FAQ

How many third-party scripts is too many?

There is no safe count. Ten small async scripts can cost less than one synchronous tag manager that loads five more files. Judge by total blocking time and by the third-party attribution in your lab report, not by the number of tags.

Does async or defer make a script free?

No. Both stop the script from blocking HTML parsing, but the download still competes for bandwidth and the execution still runs on the main thread. That is why a heavy async script can still wreck INP while leaving LCP alone.

Will a chat widget hurt my Core Web Vitals?

It shouldn't, if it loads asynchronously, stays small, and renders in an overlay rather than pushing your content around. Check three things before you install one: the script's transfer size, whether the embed code uses async or defer, and whether there's an option to load it after the page.

Does Google penalise my ranking for third-party scripts?

Not directly. Core Web Vitals are part of Google's page-experience signals, so a page that is slow for real users can rank below an equally relevant fast one — but the metrics are what counts, not the presence of third-party code. Field data is also measured over 28 days, so a fix takes weeks to show up.

Why did my PageSpeed score drop after I added one small script?

Usually because the lab score is a single simulated run and moves by several points on its own. Run each version three times and compare the individual metrics. If LCP and TBT are unchanged and only the score moved, nothing real happened.

Should I self-host a third-party script to make it faster?

Rarely worth it. You save one connection setup, but you lose the vendor's cache-control and updates, and you have to redeploy for every fix. Self-hosting is worth considering only for a stable file that never changes and whose licence allows it.

Where to go next?

Pick one page, measure it twice, and fix the single worst offender — that is usually a bigger win than shaving kilobytes off five well-behaved scripts. For the framework-specific part, adding a chat widget to Next.js covers loading strategies and route changes in a single-page app.

If you're choosing a chat tool and performance is on your list, the questions worth asking are in how to choose live chat software, and the installation methods for every platform are in how to add live chat to your website. Both are free to follow along with — a SealReply account costs nothing to open, and the install step shows you both versions of the snippet so you can test them against each other.