
Partytown Has a Free API — Run Third-Party Scripts in Web Workers
What if Google Analytics, Facebook Pixel, and every other third-party script ran in a web worker — freeing your main thread completely? Partytown by Builder.io moves third-party scripts off the main thread into a web worker. The Problem Third-party scripts are the biggest performance killer on most websites. Google Analytics alone adds 30-50ms of main thread blocking. Add Facebook Pixel, HubSpot, Intercom, and hotjar — you lose 200-400ms of interactivity. Partytown intercepts these scripts and runs them in a web worker. Your main thread stays free for your application code. How It Works <!-- Before: blocks main thread --> <script src= "https://www.googletagmanager.com/gtag/js?id=GA_ID" ></script> <!-- After: runs in web worker --> <script type= "text/partytown" src= "https://www.googletagmanager.com/gtag/js?id=GA_ID" ></script> That's the entire change. Add type="text/partytown" to any script tag. Framework Integration npm install @builder.io/partytown Next.js: import { Partytown } fro
Continue reading on Dev.to JavaScript
Opens in a new tab


