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.
In more detail
It needs the nextScriptWorkers flag. As of Next.js 15 it does not work with the App Router, so treat it as a Pages Router option.
Related terms
- Partytown — An open-source library that moves third-party scripts into a web worker so they do not slow down 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.
- main thread — The first thread a program starts with; in a browser page it also runs JavaScript and handles input, layout and painting.
Taught in
- Script Optimization: next/script & Lazy Third Parties — Next.js 15 & Modern App Router Architecture