Third-party code high
Reduce the impact of third-party code
Off-domain scripts like analytics, ads, chat, and tag managers block the main thread and slow your page's startup.
What you see
Reduce the impact of third-party code — Third-party code blocked the main thread for 740 ms Third-party code can significantly impact load performance.
What’s actually happening
You've optimized your own code and the score still won't move. The audit table lists each third party by name — Google Tag Manager, Google Analytics, Facebook, Intercom, Hotjar — with its transfer size and main-thread blocking time. Lighthouse fails the check once combined blocking time crosses 250ms. The pain is worst on first load because these scripts often run synchronously during startup.
Common causes
- A tag manager (GTM) that loads a pile of additional tags, each with its own script and main-thread cost.
- Analytics, session-replay, or heatmap scripts (Hotjar, FullStory, PostHog) that instrument the page eagerly on load.
- A live-chat widget (Intercom, Drift, Zendesk) that pulls a large bundle and an iframe before the user ever clicks it.
- Ad and consent-management scripts that block rendering while they negotiate.
- Embedded widgets — YouTube iframes, social buttons, maps — each booting their own framework.
How to fix it
- Identify the worst offenderSort the third-party table by main-thread blocking time. One or two entities usually account for most of it. Fix those before touching anything else — the long tail rarely matters.
- Facade the heavy widgetsReplace chat, video, and map embeds with a lightweight placeholder (a static image or styled button) that only loads the real script on click or hover. lite-youtube-embed and react-lite-youtube-embed are drop-in examples; most chat vendors document a deferred-load snippet.
- Defer and lazy-loadAdd defer to non-critical third-party tags, and trigger analytics/replay scripts after the load event or on first interaction rather than during startup. In GTM, move tags off the All Pages / Page View trigger to Window Loaded.
- Self-host what you canServing a script from your own domain skips a separate DNS/TCP/TLS handshake and lets you cache it. Google Analytics' gtag and many font/script files can be proxied or self-hosted.
- Audit and cutRun a regular inventory of installed tags. Marketing tools accumulate; half are usually unused. Delete the ones nobody reads anymore.
Stop it recurring
Gate new third-party tags behind a performance review and a blocking-time budget so each addition has to justify its cost.
Related errors