Speed up a marketing site by moving Google Analytics, Facebook Pixel, or chat widgets off the main browser thread
Improve Google Lighthouse performance scores without removing the third-party tools your marketing team requires
Isolate third-party scripts from your core app code so they cannot slow down user interactions like clicks and scrolls
Some third-party scripts may not work correctly inside a web worker, review the trade-offs documentation before adding to a production site.
Partytown is a small JavaScript library that solves a common website speed problem. When you add third-party tools to a website, things like analytics trackers, advertising scripts, or chat widgets, those scripts run on the browser's main thread. The main thread is also what the browser uses to display your pages and respond to user clicks and scrolls. When third-party scripts compete for that same thread, your site feels slower and scores lower on performance audits like Google Lighthouse. Partytown's approach is to move those third-party scripts off the main thread entirely, into a separate background area of the browser called a web worker. Web workers run in parallel and cannot block the main thread, so your site's own code gets priority. The third-party scripts still run and do their job (collecting analytics data, tracking conversions, and so on), but they do it without slowing down what the user sees. Using Partytown requires adding a small snippet to your HTML and marking third-party script tags with a special attribute so the library knows which ones to relocate. Configuration options let you control which scripts are moved and how they communicate back with the main page when needed. The library is designed to integrate with popular frameworks and site builders, and integrations are documented for common setups. The README notes that Partytown is still in beta and may not work correctly in every situation. The trade-offs section of the documentation explains scenarios where moving a script to a worker can cause problems, so it is worth reviewing those before adding it to a production site. The project is maintained by the Builder.io team and is related to their Qwik framework.
← qwikdev on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.