RULE: Defer or delay every third-party script until user interaction, except those required for first paint
Rule: Every third-party script on a Candid Creative client site is deferred or delayed until first user interaction, except those genuinely required for first paint (which should be rare). Default loading strategy: strategy="lazyOnload" (Next.js) or Partytown / web-worker isolation.
Why: Third-party JavaScript is the single largest avoidable INP cost (see Reference: the 8 most common INP killers — ranked by observed frequency). A GTM container with 18 tags increases TBT ~20× (Chrome Aurora team: Google Tag Manager with 18 tags increases Total Blocking Time ~20×). Most SMB sites accumulate 8-15 third-party scripts over 2-3 years without auditing the cumulative cost.
How to apply:
- Inventory third-party scripts at engagement onboarding; rank by ROI
- For Next.js:
next/scriptwithstrategy="lazyOnload"for analytics, chat, A/B testing, heatmaps - For others: Partytown to move 3rd-party JS to a web worker
- Anti-flicker holds on A/B testing tools (Optimizely, VWO) cost both LCP and INP — re-evaluate quarterly whether the test is worth the perf penalty
- Chat widgets (Intercom, Drift, HubSpot): only load on click of a chat trigger, never on page load
- One-script-in, one-out rule: net script count never grows without explicit justification
Pairs with RULE: Performance budgets enforced in CI. Build fails on budget violation. Documented budgets without CI enforcement do not work. for governance.