Orofold Labs

Launching soon

Notes Get in touch

Performance and accessibility 4 min read Updated

The real cost of third-party scripts

In short

A third-party script costs your visitors time even when it is small, so load it with care and remove what adds no clear value.

One line of HTML from an analytics service, a chat widget or a video embed adds requests, render delays and main-thread work that the reader never asked for. Start by listing what runs on the site, then decide how each piece loads. Load scripts that need not run at once asynchronously, and replace heavy embeds with a facade.

Why third-party code costs more than it looks

The file is not the only cost. A synchronous script delays the building and rendering of the page, because the browser has to stop and wait for it. web.dev states that embedded third-party resources can significantly slow down page loading if they are built poorly. The owner of the script decides how heavy it is, but your site carries the delay.

The work a script does also competes with the reader. Long tasks on the main thread delay responses to clicks and taps, so a widget that looks harmless can make the page feel slow. The article on fixing Interaction to Next Paint explains how those tasks are found and broken up.

Async, defer or a facade

Two attributes on the script tag decide when a script runs. The sources describe the difference as follows:

  • An async script executes at the first opportunity after it has downloaded. It may run before parsing finishes, and async scripts do not necessarily run in the order they appear.
  • A defer script executes after HTML parsing is completely finished. It keeps the order in which the scripts appear, and it does not block the parser.

web.dev advises loading third-party scripts asynchronously unless the script has to run before the page can be rendered. Where a script is heavy and is not needed to draw the page, a facade is the next option. A facade is a static element that looks similar to the embed. On mouseover it preconnects to the third-party resources, and on click it replaces itself with the real product.

OptionUse it whenWhat you give up
AsyncThe script does not need to run before the page is renderedNo guaranteed order between scripts
DeferScripts must run in the order they appear, after parsingThe script waits until parsing is complete
FacadeA heavy embed, such as a video player or chat widget, is not needed at onceThe facade lacks the full functionality of the real embed
RemovalThe script adds no clear value to the pageThe feature disappears

Working on something similar in your own product? A few honest sentences are enough – we read every enquiry and reply by email. Apply with your idea

Audit what you run

Most sites carry more third-party code than anyone can name. Start by listing every script and frame that loads from another domain. For each one, write down its purpose, its owner and where it was added. The Lighthouse audit that flagged embeds for facades was removed in Lighthouse 13, so the list has to be made by hand, for example from the network panel of the browser’s developer tools.

Then check each item for one thing: whether it adds clear value to this site. web.dev recommends removing a third-party script that does not. A tag added for a campaign that has ended is a common first candidate.

The advice to audit and remove scripts is general practice. The statements about async, defer, facades and the Lighthouse audit come from the cited sources.

Sources and limits

A practical checklist

Work through the list in order, and measure before and after each change so that the effect is visible.

  1. Write down every third-party domain, with the purpose and owner of each script.
  2. Remove scripts that no longer add clear value, starting with tags for campaigns that have ended.
  3. Load each remaining script with async, unless it must run before the page can be rendered.
  4. Use defer where scripts depend on the order in which they appear.
  5. Replace heavy video or chat embeds with a facade, and test on a phone the features you have given up.
  6. Compare field data over a period that covers normal traffic, as explained in field data from real visitors, and turn the result into a limit using performance budgets.

Common questions

Is async always the right choice for a third-party script?
Not always. web.dev advises async unless the script has to run before the page can be rendered. Use defer when the order of the scripts matters.
What does a facade lose compared with the real embed?
A facade lacks the full functionality of the real embed. Lazily loaded videos may not autoplay reliably, so check each feature you rely on.
Why is a small script still expensive?
File size is only part of the cost. A synchronous script also delays the page while it is downloaded and run, and that delay falls on your visitors even though someone else wrote the code.

Sources

  1. Efficiently load third-party JavaScript | Articles | web.dev, web.dev. Accessed 24 November 2026
  2. Lazy load third-party resources with facades | Lighthouse | Chrome for Developers, Chrome for Developers. Accessed 24 November 2026

Further reading

Have an idea that should exist? Or a working product that needs more customers, a new website or a complete rework? Bring us anything. Apply with your idea

All notes