💖 Using Webpack? You want workerize-loader ➡️
Workerize
Moves a module into a Web Worker, automatically reflecting exported functions as asynchronous proxies.
- Bundles a tiny, purpose-built RPC implementation into your app
- If exported module methods are already async, signature is unchanged
- Supports synchronous and asynchronous worker functions
- Works beautifully with async/await
- Just 800 bytes of gzipped ES3
Install
npm install --save workerize
Usage
Pass either a function or a string containing code.
worker.js:
let worker = ; async { console; console;};