To stop third-party scripts slowing your website, list every script your pages load, remove the ones nobody uses, and delay the rest until they are needed. Load tags with async or defer, fire non-essential tags after the page has loaded, and replace chat widgets and video embeds with lightweight "facades" that load the real thing on click.
This guide shows how to find out which third parties are costing you speed, why they hurt Core Web Vitals, and practical fixes for chat widgets, tag managers, embeds and tracking pixels.
Key takeaways
- List every third-party script your pages load and remove any without an owner, because removing a script is the only fix that costs nothing.
- Load the scripts you keep with async or defer, and fire non-essential tag manager tags after Window Loaded rather than on page view.
- Replace chat widgets and YouTube embeds with lightweight facades that load the real widget or player only when a visitor clicks.
- Third-party JavaScript running on the main thread harms Interaction to Next Paint, while widgets injected late hurt Cumulative Layout Shift.
What counts as a third-party script?
Any code your page loads from a domain you do not control. Common examples on small-business sites:
- Analytics and tag managers
- Live chat and chatbot widgets
- Cookie consent banners
- Advertising and remarketing pixels
- Heatmap and session-recording tools
- Embedded YouTube, Vimeo, Google Maps and social media posts
- Review, booking and payment widgets
- A/B testing tools
Each one usually loads its own JavaScript, which may in turn load more scripts from more domains.
Why do third-party scripts slow my site down?
They cost speed in three ways:
- Network. Each new domain needs a DNS lookup, connection and TLS handshake before anything downloads. Web.dev estimates early connections can save 100 to 500 ms per important third-party origin, which shows how much the connection alone can cost.
- Main thread. JavaScript has to be parsed and run on the visitor's device. While a chat widget or tag is running, the page cannot respond to taps, which harms Interaction to Next Paint (INP).
- Layout. Banners, adverts and widgets that inject content after the page has drawn push things around, hurting Cumulative Layout Shift.
Google's guidance on tag managers notes a correlation between larger tag manager containers and poorer INP. One tag rarely matters on its own; a dozen together usually do.
How do I find which third-party scripts are slowing my site?
- Run PageSpeed Insights and open the Lighthouse report. The 3rd parties insight lists each third-party provider with its transfer size and main-thread time.
- Open Chrome DevTools, Network tab, reload with cache disabled, and sort by domain. Note every domain that is not yours.
- Use the Performance panel to record a page load. Long yellow blocks of scripting time labelled with third-party URLs are your main-thread culprits.
- Test with scripts blocked. In DevTools, right-click a request and choose Block request domain, then reload. Compare LCP and Total Blocking Time with and without it.
The MakeItFlow technology detection check also lists the analytics, chat, marketing and other tools it detects on a site, which gives you an inventory to start the conversation with whoever added them.
How do I decide which scripts to keep?
For each script, ask:
- Who asked for it, and are they still here?
- Is anyone looking at the data or using the feature?
- Does it need to be on every page, or only some?
- Does it need to load immediately, or can it wait?
Remove anything without an owner. Paused campaigns, old heatmap tools and duplicate analytics are common finds. Removing a script is the only fix that costs nothing.
How should I load the scripts I keep?
Use async or defer so the script does not block the page from rendering:
<!-- Runs as soon as it downloads, order not guaranteed -->
<script async src="https://analytics.example.com/tag.js"></script>
<!-- Runs after HTML parsing, in order -->
<script defer src="https://widgets.example.com/reviews.js"></script>
async suits independent scripts like analytics that should start early. defer suits anything that can wait until the page is parsed. For important third-party domains you will definitely use, add a preconnect, but keep it to two or three, because the browser closes unused connections after about 10 seconds:
<link rel="preconnect" href="https://www.googletagmanager.com">
How do I stop a chat widget slowing my site?
Chat widgets are among the heaviest third-party scripts, and most visitors never open them. Use a facade: show a lightweight button styled like the chat launcher, and load the real widget only when someone clicks it or after the visitor has been on the page a while.
<button id="chat-launcher" type="button" aria-label="Open chat">Chat with us</button>
<script>
document.getElementById('chat-launcher').addEventListener('click', function () {
var s = document.createElement('script');
s.src = 'https://chat.example.com/widget.js';
s.async = true;
document.body.appendChild(s);
this.remove();
}, { once: true });
</script>
Check your provider's documentation: many offer a "load on demand" option or an API to open the widget once loaded. Open-source libraries such as react-live-chat-loader handle this for several chat providers.
How do I stop YouTube and Google Maps embeds slowing my page?
A standard YouTube embed loads the full player, its JavaScript and fonts even if nobody presses play. Use a facade such as lite-youtube-embed, which shows the thumbnail and loads the player on click. Similar libraries exist for Vimeo. Google's documentation notes one trade-off: autoplay may not work consistently with a facade.
For maps and other iframes below the fold, add loading="lazy":
<iframe src="https://www.google.com/maps/embed?pb=..." width="600" height="450"
loading="lazy" title="Map showing our Leeds office"></iframe>
Our Google Maps embed generator can build this iframe code from an address, with lazy loading switched on. On a contact page, a static map image linking to Google Maps is lighter still.
How do I make Google Tag Manager faster?
Google's web.dev guidance on tags and tag managers recommends:
- Fire non-essential tags after
Window Loaded, not on page view. - Prefer image pixels and built-in templates over custom HTML tags, which are the most expensive kind.
- Remove or pause unused tags rather than blocking them with trigger exceptions, which leaves the code in the container.
- Keep core features out of the tag manager. Hero images, cookie banners and site functionality loaded through a tag manager appear later and can worsen LCP and CLS.
- Consider server-side tagging on larger sites, which moves vendor code off the visitor's device.
Fire tags only on the pages that need them. A conversion pixel only needs to run on the thank-you page.
Does cookie consent help with third-party scripts?
Under UK and EU rules, most non-essential tracking and marketing scripts should not run until the visitor has consented. Setting your consent tool to genuinely hold those scripts back until consent is given is a legal requirement there and a speed win for everyone who declines. US privacy laws such as California's CCPA mostly work on an opt-out basis instead, so check the rules for the places your visitors are. Our guide to the Data (Use and Access) Act and cookie consent covers the current rules. MakeItFlow does not scan cookie consent, so use a dedicated consent-scanning tool if you need to verify which cookies are set.
Frequently asked questions
Should I self-host third-party scripts?
Self-hosting gives you control over caching and removes an extra connection, and web.dev cites a case where self-hosting an A/B testing script saved 1.7 seconds. The downside is that your copy goes out of date and misses vendor fixes. It suits small, stable libraries better than analytics or chat scripts that change often.
Do third-party scripts affect my PageSpeed score?
Yes. Their download and main-thread time count towards Total Blocking Time and can delay LCP, both of which feed the Lighthouse score. In real-user data they mainly show up as poor INP.
What is the lightest way to run analytics?
Load the analytics script with async, avoid stacking several analytics tools that do the same job, and do not add session recording to every page. Some privacy-focused analytics tools are much smaller than mainstream ones, which is worth considering if you only need basic visitor numbers.
Can I move third-party scripts to a web worker?
Libraries such as Partytown run some third-party scripts in a web worker, off the main thread. It can help, but not every script is compatible, so test thoroughly. Removing and delaying scripts is simpler and should come first.
How often should I audit third-party scripts?
At least every quarter, and after every marketing campaign ends. Scripts accumulate quietly, and nobody tends to remove them unless someone checks.
What to do next
Make a list of every third-party domain on your home page today, put an owner next to each, and remove anything without one. Then defer or facade the rest and re-test INP and LCP. Our guide to fixing Interaction to Next Paint goes deeper on main-thread work, or you can run a free website audit with MakeItFlow to see your Core Web Vitals and detected technologies in one report.
Related reading
- Why Are My Web Fonts Slowing My Site Down? How to Fix It: Web fonts slowing your site? Cut font files, use WOFF2, set font-display, preload the main font and consider self-hosting and subsetting for faster text.
Sources
More guides for your industry
Free checklist (PDF)
Free gyms & fitness website checklist
30 practical checks for gyms & fitness: website speed and mobile, Google Business Profile and reviews, email security, booking and enquiry handling, and AI search visibility. Each one says why it matters, and many link to a free tool that checks it.
Written by the MakeItFlow team
We build the website audit these guides are based on. Every fact is checked against the primary sources listed above and this guide was last reviewed on 30 October 2026 . How we research and check
Check your own site in 30 seconds
Run a free audit covering speed, SEO, DNS, email authentication and security headers — and get a prioritised fix list.