{"id":"yrp2asfz408dppn","title":"Third-Party Scripts: The Performance Cost Marketing Underestimates","slug":"third-party-scripts-performance-cost","summary":"Analytics, chat widgets, and A/B snippets run on your main thread, not theirs. I inventory, defer, and delete with data.","imageUrl":"https://briancrabtree.me/images/journal-third-party-scripts-performance-cost.webp","category":"Performance","date":"2026-03-16T18:00:00.000Z","featured":false,"likes":30,"author":"Brian Crabtree","content":"<h2>You rent their JavaScript forever</h2>\n\n<p>Every tag manager publish can add synchronous scripts to LCP. Sales signs the contract; engineering inherits the TBT. I export tag containers and map each tag to owner, purpose, and kill switch.</p>\n\n<p>If a vendor cannot explain what their script does on first load, it stays off until they can.</p>\n\n<p>Session replay tools are heavy. If product insists, sample rate below 10 percent and exclude password fields by contract.</p>\n\n<h2>Categories by risk</h2>\n\n<p>Analytics can defer until after load or interaction with buffered beacons. Chat widgets often inject iframes and polling loops immediately. Personalization engines rewrite DOM and destroy CLS. Heatmaps sample clicks but cost continuous listeners.</p>\n\n<p>I classify: block render, block interaction, idle only. Only idle only gets a pass without negotiation.</p>\n\n<p>LinkedIn Insight and Meta pixels often load synchronously in GTM triggers configured by non-engineers. I lock trigger sequences in version control.</p>\n\n<h2>Loading strategies that help</h2>\n\n<p>facade pattern for chat: button looks like widget, real script loads on click. Partytown moves some work off main thread but not all vendors support it. Self-hosting gtag locally still executes Google logic; bytes move, CPU often does not.</p>\n\n<p>Consent banners should not themselves be 200 KB React apps unless legal insists. I keep CMP small and load non-essential tags after consent signal.</p>\n\n<p>SRI on third-party scripts is rare because vendors rotate files. Self-hosting analytics proxy is alternative with ops cost.</p>\n\n<h2>Measuring in production</h2>\n\n<p>Chrome DevTools third-party summary, Lighthouse bootup time, and RUM if you have it. I run PSI with and without blocklists using WebPageTest custom blocks to estimate savings before political fights.</p>\n\n<p>Publish the delta to stakeholders in milliseconds of main-thread time, not vague slow site language.</p>\n\n<p>document.write injection from old tags still appears in affiliate scripts. I block at CSP and force vendor update.</p>\n\n<h2>Contracts and SLAs</h2>\n\n<p>Performance clauses in vendor renewals: max tag size, async required, single endpoint domain allowlist. Marketing keeps tools; engineering keeps budgets.</p>\n\n<p>When a tool is only used quarterly, remove it between campaigns instead of leaving zombie tags.</p>\n\n<p>INP regressions after GTM publish should roll back container version the same way bad deploys roll back git.</p>\n\n<h2>On this site</h2>\n\n<p>I keep third-party weight low on briancrabtree.me so lab scores reflect our code, not a tag soup. Client sites get the same discipline after analytics requirements are written down, not assumed.</p>\n\n<p>I maintain a spreadsheet: tag name, owner, KB, last reviewed date. Quarterly review deletes more than annual big bang.</p>\n\n<p>When I audit performance stacks, On this site is where hours disappear if nobody owns the outcome. I write before-and-after notes, attach PSI or waterfall screenshots, and leave the team a three-item follow-up list. Reproducible wins beat toolchain debates in sprint review. If this section matches your bottleneck, send the URL and whether LCP, INP, CLS, or crawl coverage is the pain point.</p>\n\n<h2>Next step</h2>\n\n<p>Send your tag manager export or view-source script list. I return defer, facade, delete with expected INP improvement. Third-party is the fastest perf win that does not touch your design system.</p>\n\n<p>Client education: marketing pixels are not free like air. They are rent paid in milliseconds every page load.</p>\n\n<p>When I audit performance stacks, Next step is where hours disappear if nobody owns the outcome. I write before-and-after notes, attach PSI or waterfall screenshots, and leave the team a three-item follow-up list. Reproducible wins beat toolchain debates in sprint review. If this section matches your bottleneck, send the URL and whether LCP, INP, CLS, or crawl coverage is the pain point. For a related angle I keep coming back to, see <a href=\"/journal/tag-manager-performance-tax/\">Google Tag Manager Performance Tax (What Marketing Adds to TBT)</a>.</p>","tags":["third-party","performance","analytics"],"views":89}