Third-Party Code: What Other Companies Add to Your Page
Third-party code is anything your page loads from another company’s servers: analytics, tag managers, advertising, chat widgets, video and map embeds, social buttons, A/B testing tools, consent banners, font services. Each one is useful to someone, but each also adds downloads and, usually, JavaScript that runs on your visitors’ devices.
Why it matters
You don’t control third-party code. A tag can grow, add further scripts of its own, or slow down on its provider’s side, and your page pays for it. Together, third parties are often responsible for a large share of a page’s main-thread time, which shows up as Total Blocking Time in the lab and slow Interaction to Next Paint for real visitors. Each new origin also needs its own DNS lookup and connection.
Common sources
- Tag managers that have collected years of tags, some for tools nobody uses any more.
- Chat and support widgets that load a full application on every page, before anyone opens them.
- Video and map embeds, where one embedded player can load several hundred kilobytes of JavaScript even if the visitor never presses play.
- Several analytics or marketing tools that measure the same thing.
- Font services that add extra origins to the critical path.
How to fix
Audit and remove
List every third party on the page (the PerfoMetrix report shows the heaviest ones) and ask, for each, who uses it and for what. Remove tags from tools you no longer use, and pause tags in your tag manager that belong to finished campaigns.
Load later
Most third-party scripts don’t need to run before the page is shown. Use async or defer, load
them after the page has finished loading, or only on pages where they are needed. A chat widget,
for example, can be loaded on the contact and pricing pages only, or when the visitor clicks a
“Chat with us” button.
Use facades for heavy embeds
A facade is a lightweight placeholder, usually an image with a play button, that looks like the
embed and loads the real one only when the visitor interacts with it. For YouTube, Lighthouse’s
documentation lists open-source facades such as lite-youtube-embed:
<lite-youtube videoid="VIDEO_ID" playlabel="Play: Product tour"></lite-youtube>
The same idea works for maps (a static image linking to the map) and chat widgets (a button that loads the widget on click).
Load only after consent
If you use a consent banner, scripts that require consent, such as advertising or marketing tags, shouldn’t load before the visitor agrees. That is a legal requirement in many regions and also keeps the first page view lighter. Check that your consent tool actually blocks these tags until consent is given.
Self-host fonts
Serving fonts from your own domain removes an external connection from the critical path. See the web fonts guide.
Connect early to the ones you keep
For a third-party origin needed early in the page load, a preconnect hint saves connection time:
<link rel="preconnect" href="https://cdn.example-widget.com" />
Use it for one or two critical origins only; preconnecting to many origins wastes effort.
WordPress
Plugins often add their own third-party scripts on every page. Disable plugins you don’t use, and check plugin settings for options to load scripts only on specific pages or after interaction.
How PerfoMetrix checks this
We read Lighthouse’s third parties audit (third-parties-insight) from the PageSpeed Insights
run we already make (mobile, simulated device). This check is information only, not passed or
failed: we show how many third parties Lighthouse found and the first five it lists, with the
main-thread time each one adds. The full Lighthouse audit also reports their transfer sizes.
This check is shown but doesn’t count toward the performance score: the effect of third-party code is already measured by TBT, FCP and LCP, which are scored. No extra requests are made to your site.