Partytown
An open-source library that moves third-party scripts into a web worker so they do not slow down the main thread.
In more detail
It forwards the scripts' DOM access to the main thread behind the scenes. next/script's worker strategy is built on it.
Related terms
- worker strategy — An experimental next/script strategy that runs a third-party script in a web worker using Partytown, keeping it off the main thread.
- Web Worker — A script that runs on its own background thread, separate from the page's main thread, so heavy computation does not freeze the page.
Taught in
- Script Optimization: next/script & Lazy Third Parties — Next.js 15 & Modern App Router Architecture