Audit and minimize third-party scripts (analytics, chat widgets, ad trackers). Each third-party script adds DNS lookups, TLS handshakes, and JavaScript execution that blocks the main thread — a single chat widget can add 500ms+ to page load and degrade Core Web Vitals scores.
Why This Matters
Each third-party script adds 1-3 network requests (DNS, TLS, download), blocks the main thread during parse/execute, and often loads additional scripts of its own. A typical marketing stack (analytics + chat + A/B testing + ads) can add 2-5 seconds to page load time and 1MB+ of JavaScript that you do not control.
Third-party scripts (analytics, chat widgets, A/B testing, ad trackers, social embeds) are the single largest source of uncontrolled performance degradation on most websites. Unlike your own code, you cannot optimize, tree-shake, or code-split third-party scripts.
Each third-party script incurs costs that compound:
Network cost: DNS lookup + TLS handshake + download for each origin (typically 100-500ms per script on mobile)
Parse/execute cost: JavaScript parsing and execution blocks the main thread, delaying user interaction
Cascade cost: Many scripts load additional scripts (e.g., a chat widget loads its own analytics), creating unpredictable waterfall chains
Ongoing cost: Third-party scripts update without your knowledge — a vendor's "minor update" can add 200KB to your bundle overnight
Studies show that removing a single chat widget can improve LCP by 500ms+ and TTI by over 1 second.
The rule
Audit all third-party scripts quarterly. Load essential scripts asynchronously with async or defer. Remove scripts that are not actively used or whose value does not justify their performance cost. Use next/script with strategy="lazyOnload" for non-critical scripts.
Bad example
<!-- Blocking scripts in <head> — all execute before page renders --><head> <script src="https://analytics.example.com/tracker.js"></script> <script src="https://chat.example.com/widget.js"></script> <script src="https://ab-testing.example.com/experiments.js"></script> <script src="https://social.example.com/share-buttons.js"></script> <script src="https://ads.example.com/prebid.js"></script></head>
Good example
// next/script with appropriate loading strategiesimport Script from "next/script";// Analytics — load after page is interactive<Script src="https://analytics.example.com/tracker.js" strategy="afterInteractive"/>// Chat widget — load only when page is idle<Script src="https://chat.example.com/widget.js" strategy="lazyOnload"/>// Remove unused scripts entirely// ❌ A/B testing (not used since Q2)// ❌ Social share buttons (0.1% click rate)// ❌ Ad prebid (no ad revenue)