Performance
How to Audit Third-Party Scripts That Slow Your Site
EyeCaptain

How to Audit Third-Party Scripts That Slow Your Site

Find, measure and cut the third-party scripts slowing your pages, with a step-by-step audit using Lighthouse, DevTools and Google Tag Manager.

Dimitris Andreadakis

6 min read
68 views
third-party scripts auditthird-party scripts page speedreduce impact of third-party codethird-party javascript performancegoogle tag manager page speed

Most slow pages are not slow because of the store theme or the product images. They are slow because of everything that was added on top: a chat widget, two analytics tags, a review app, a heatmap tool someone tried last spring, a consent banner, three ad pixels and a pop-up builder. Each one looked harmless on the day it was installed. Together they compete with your own code for the same browser, on the same phone, at the moment a shopper is deciding whether to stay.

This guide shows you how to audit third-party scripts step by step: how to list what is actually loading, measure what each script costs, decide what stays, and load the survivors in a way that does not block the page.

Why third-party scripts deserve their own audit

Third-party code is close to universal. The HTTP Archive found that 92% of pages load at least one third party, with a median of 66 third parties on the top thousand websites and 27 across the top million. Scripts are the most common content type among those requests.

The problem is not that these tools exist. Analytics, consent management and payment widgets are often necessary. The problem is that nobody owns the total. Marketing adds a pixel, the support team adds chat, a developer adds a font service, and no one checks the combined effect on load time and responsiveness. Because the scripts live on someone else's server, their size and behaviour can also change after you install them, without a single change to your own site.

The cost shows up in the metrics that matter for conversions. Heavy scripts delay rendering and push back your Largest Contentful Paint on product pages. Long JavaScript tasks keep the main thread busy, so taps on "Add to cart" feel sluggish, which is exactly what Interaction to Next Paint measures. Widgets that inject banners or badges after load cause layout shifts that move buttons under the shopper's finger.

Step 1: Build an inventory of every script

You cannot cut what you cannot see. Start with a plain list, and build it from what the browser actually loads rather than from what people remember installing.

  1. Open your three most important templates in Chrome: the homepage, a product or landing page, and the checkout or lead form.
  2. Open DevTools, go to the Network panel, filter by "JS", and reload with the cache disabled.
  3. Sort by domain. Every domain that is not yours is a third party. Note the domain, the file size and what the tool is for.
  4. Open Google Tag Manager and list every tag, trigger and the pages it fires on. Tags often load more scripts of their own, so the Network panel list will usually be longer than the tag list.
  5. Check your platform's app or plugin list. Shopify apps, WordPress plugins and similar add-ons often inject scripts that never appear in your tag manager.

Put everything in one sheet with these columns: script or vendor, owner inside your team, business purpose, pages it loads on, transfer size, and whether it loads before or after the page renders. The "owner" column is the most useful one. A script with no owner is usually a script nobody needs.

Step 2: Measure what each script costs

File size is only part of the cost. A small script that runs a lot of JavaScript on the main thread can hurt more than a large image. Use these checks:

  • Lighthouse third-party report: Run Lighthouse or PageSpeed Insights on each key template. The third-party section groups transfer size and main-thread time by vendor, which gives you a ranked list in a few seconds.
  • Network request blocking: In DevTools, right-click a request and choose "Block request domain", then reload and compare the Performance panel. Doing this for one vendor at a time shows what the page would look like without it.
  • Performance panel on a throttled phone profile: Record a page load with CPU throttling on. Look for long tasks (marked in red) and check which script they belong to. Many third-party problems are invisible on a fast laptop and obvious on a mid-range phone.
  • Field data: Lab tests show potential problems; field data shows real ones. Compare the Core Web Vitals report in Search Console before and after any change.

Add two columns to your sheet: blocking time and whether removing the script changed LCP, INP or layout stability. Now each script has a cost next to its purpose.

EyeCaptainEyeCaptain
Conversions Booster

Problems you can't see are costing you sales

The average website has 23+ hidden conversion killers. From slow load times to invisible UX bugs — our AI finds what humans miss.

Mobile-first gaps

Step 3: Decide what stays

Go through the list with the owners and give every script one of four labels.

DecisionWhen it appliesTypical examples
RemoveNo owner, no current use, or a duplicate of another toolOld test tools, a second analytics tag, pixels for ad channels you paused
RestrictNeeded, but not on every pageReview widgets only on product pages, a booking widget only on the booking page
DelayNeeded, but not before the shopper sees the pageChat, social embeds, video players below the fold
Keep as isRequired early for the page to work or to stay compliantConsent management, payment scripts on checkout

Duplicates are the quickest win. It is common to find the same analytics data collected twice, once through a platform integration and once through a tag manager, or two different behaviour recording tools running side by side. Pick one, confirm it records correctly, then remove the other.

Be strict with checkout. Every script that loads on the checkout page is both a speed cost and a risk, because it runs where shoppers type addresses and card details. If a script has no clear job on checkout, restrict it to other pages.

Step 4: Load the scripts you keep in a better way

For the scripts that stay, the loading method often matters as much as the script itself. Google's guide to loading third-party JavaScript efficiently recommends loading third-party scripts asynchronously unless they have to run before the page can render. In practice:

Use async and defer

Add "async" to scripts that should run as soon as they arrive but do not need to block rendering, such as analytics. Use "defer" for less critical scripts so they run after the HTML is parsed. A synchronous script in the head stops the browser from showing anything until it has downloaded and run.

Connect early to the origins that matter

For the one or two third-party origins that are critical, add a preconnect hint so the browser opens the connection early. The same Google guide says early connections to important origins can save 100 to 500 ms. Use "dns-prefetch" for less important domains, and do not preconnect to everything, because each connection has a cost.

Load on interaction with a facade

Chat widgets and video embeds are good candidates for a facade: show a lightweight static button or thumbnail, and load the real script only when the visitor clicks it. Most visitors never open the chat, so most visitors never pay for it.

Set triggers in your tag manager

In Google Tag Manager, move non-essential tags from "Page View" to "Window Loaded" or to a timer or scroll trigger. Restrict tags to the page paths where they are needed rather than firing on all pages.

Consider server-side tagging for ad pixels

If several ad platforms each load their own pixel, a server-side setup can replace many browser scripts with one request to your own endpoint. Our guide to GA4 server-side tagging covers how this works and what it costs to run.

Step 5: Reserve space for injected widgets

Review badges, promo bars, cookie banners and recommendation carousels often appear a moment after the page loads and push content down. If your product page has a star rating that loads late, reserve its height in CSS so the title and price do not jump. Show consent banners as an overlay at the bottom of the screen instead of inserting them above the header. Our article on layout shifts that cost sales covers how to find and fix these shifts.

Step 6: Make the audit a routine

Third-party bloat comes back unless someone watches it. A few habits keep it under control:

  • Add a simple rule: any new script needs an owner, a purpose and an end date before it goes live.
  • Review the script sheet every quarter and remove anything whose trial or campaign has ended.
  • Re-run Lighthouse on key templates after every new app, plugin or tag.
  • Watch the Core Web Vitals report in Search Console for sudden changes. A vendor can ship a heavier script without telling you.
  • Agree on a budget, such as a maximum number of third-party domains per template.

Speed is only one part of why a page converts or does not. If you want to see how your page performs on speed, layout and the elements that pull attention, start with a free CRO audit of one page.

Enjoyed this article?

One short email a week with practical CRO and UX tips

No spam. Unsubscribe anytime.

Find what stops your visitors from converting

EyeCaptain is an AI-powered CRO & UX audit tool that automatically scans your pages, identifies UX issues, and gives you actionable optimization suggestions to increase conversions. Try it for free, no card, no commitment.

Free Website Audit
Share this article
LinkedIn X

About the author

Founder of EyeCaptain. Writes about conversion rate optimization, UX analysis and the neuromarketing behind pages that actually sell.

More articles by Dimitris Andreadakis