
Partytown Has a Free Library That Moves Third-Party Scripts Off the Main Thread
Google Analytics, Facebook Pixel, HubSpot, Intercom — your page loads 500KB of third-party JavaScript that blocks rendering. Partytown moves it all to a Web Worker , freeing your main thread. The Problem Third-party scripts are the #1 cause of poor Core Web Vitals: Google Tag Manager: 100-300ms blocking time Analytics scripts: 50-200ms each Chat widgets: 200-500ms Ad tracking: 100-400ms Total: 500ms-1.5s of main thread blocking before your app becomes interactive. How Partytown Works Main Thread (your code) Web Worker (3rd party scripts) ┌──────────────────┐ ┌──────────────────────┐ │ Your React app │ │ Google Analytics │ │ User interactions│ ←───→ │ Facebook Pixel │ │ Smooth 60fps │ proxy │ HubSpot tracking │ │ │ │ Intercom widget │ └──────────────────┘ └──────────────────────┘ Partytown proxies DOM access from the worker thread. Third-party scripts run as if they are on the main thread but they are actually isolated. Setup (Next.js) npm install @builder.io/partytown // app/layout.tsx
Continue reading on Dev.to JavaScript
Opens in a new tab



