Key takeaways
- Third-party scripts — analytics, ads, chat, heatmaps, social widgets — are often the biggest cause of poor INP and slow loads.
- Audit them regularly: remove what nobody uses, delay what isn’t critical, and lazy-load embeds.
- Self-host or proxy where possible, and keep everything under one tag manager with clear ownership.
Your own code might be lean, but the moment marketing adds a pixel, a heatmap, a chat widget and two A/B testing tools, the page can double in weight. Each vendor’s script runs on your visitors’ phones, competes for the main thread and can break when the vendor has an outage. Here’s how to keep them under control.
Step 1: inventory every third party#
- Run PageSpeed Insights and open “Reduce the impact of third-party code” — it lists each provider’s transfer size and main-thread time.
- In DevTools → Network, filter by domain to see every external request.
- Export all tags from Google Tag Manager.
- For each, record: owner, purpose, last time anyone used the data, pages it’s needed on.
Step 2: remove, replace or reduce#
| Script | Typical fix |
|---|---|
| Unused pixels from old campaigns | Remove |
| Two analytics tools doing the same job | Keep one |
| Heatmap / session recording | Run only during research periods, on selected pages |
| Chat widget | Load on interaction, or use a lightweight built-in assistant |
| Social feed widgets | Replace with static links or periodic screenshots |
| YouTube / Maps embeds | Facades — see embeds guide |
| Font services | Self-host — see web fonts guide |
This site’s assistant, Ask Ifti, is built into the theme and loads with a small deferred script instead of a third-party chat platform, for exactly this reason.
Need a hand with this?
Get a quick, honest review of your website’s SEO.
Step 3: control how the rest load#
- async/defer for every external script — see defer vs async.
- Delay until interaction for non-critical tags (chat, heatmaps, social pixels).
- Load per page: booking widgets only on booking pages; e-commerce pixels only where needed.
- Preconnect only to the one or two most critical third-party origins.
- Tag Manager hygiene: trigger tags on specific events/pages, not “All pages” by default.
Advanced options#
- Server-side tagging (server-side GTM) moves vendor processing off the visitor’s device.
- Partytown runs some third-party scripts in a web worker, off the main thread.
- Consent mode avoids loading marketing tags until visitors agree, which also helps privacy compliance.
Reliability and security#
- A slow vendor shouldn’t block your page — never load third-party scripts synchronously in the head.
- Use Subresource Integrity (
integrity) for static library files from CDNs. - Consider a Content Security Policy listing allowed script sources.
- Review new tag requests: who needs it, for how long, and what data it collects.
Third-party scripts FAQ#
Does Google Analytics slow my site?#
GA4 loaded asynchronously has a modest impact. The bigger problems are usually many tags stacked together.
Is Google Tag Manager bad for performance?#
GTM itself is reasonable; what you put inside it determines the cost. Audit and trim the tags.
How do third-party scripts affect Core Web Vitals?#
They mostly hurt INP (main-thread work) and sometimes LCP (bandwidth competition) and CLS (injected widgets).