Partytown is a library designed to offload resource-intensive third-party scripts to background web workers. By executing these scripts outside of the main thread, it prevents them from blocking the critical rendering path, thereby maintaining a responsive user interface and improving overall page load performance.
The project functions as a web worker proxy library that synchronizes browser interfaces between the main thread and background environments. It uses proxy-based access and synchronous messaging to replicate global objects like the window and document, allowing scripts to interact with the DOM and browser APIs from a worker thread. To ensure compatibility, it includes request proxying to bypass cross-origin restrictions and provides fallback execution mechanisms for environments where background processing is limited.
Beyond core offloading, the library offers granular control over script execution through filtering, event forwarding, and configuration settings. It includes diagnostic utilities for auditing third-party activity and tracing script execution, as well as security features for managing storage isolation and content security policies. The library operates as a standalone utility, requiring no specific framework integration or complex build-time modifications to deploy.