--- title: "Third-Party Script Sandboxing" category: studio-standards status: recommended url: https://webspecification.com/spec/studio-standards/third-party-sandboxing/ source_repo: undefined licence: CC-BY-4.0 --- # Third-Party Script Sandboxing > Offloading all tracking and marketing tags to Web Workers. ## What is it? The architectural practice of intercepting all third-party scripts (Google Analytics, Meta Pixel, Intercom, Hotjar) and executing them inside a background Web Worker, rather than on the browser's main UI thread. ## Why does it matter? You can engineer the fastest website in the world, but the moment marketing injects Google Tag Manager, your performance scores will plummet. Third-party scripts execute synchronous DOM operations and heavy tracking loops that freeze the main thread, making your site feel unresponsive. Sandboxing them ensures your UI thread remains 100% dedicated to user interactions. ## How to implement it ### 1. Use Partytown Implement a library like Builder.io's Partytown. It proxies DOM operations inside a Web Worker, tricking the third-party scripts into thinking they are running on the main thread. ```html
``` ## Verification - Check the Chrome DevTools Performance tab. Expand the "Main" thread lane. You should see virtually zero JavaScript execution time attributed to analytics or marketing domains.