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.
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.
BeforeMerge scans your pull requests against this rule and 4+ others. Get actionable feedback before code ships.
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:
Studies show that removing a single chat widget can improve LCP by 500ms+ and TTI by over 1 second.
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.
<!-- 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>// next/script with appropriate loading strategies
import 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)Search for third-party script includes:
grep -rn '<script.*src=.*https://\|Script.*src=.*https://' --include="*.tsx" --include="*.html"Use Chrome DevTools Network tab filtered to "Third-party" to see all external requests and their impact.
async, defer, or next/script strategy="lazyOnload"