Cross-Platform Web Workers
JSON →`web-worker` is a JavaScript library providing a consistent, cross-platform Web Worker API that operates natively in both browser environments and Node.js. It achieves this by aliasing to the browser's native `Worker` constructor when bundled for the browser and implementing a web-compatible `Worker` atop Node.js's `worker_threads` module. The current stable version is 1.5.0, with a fairly active release cadence addressing bug fixes, compatibility improvements, and new features like Bun support and `importScripts()`. Key differentiators include its ability to make worker code compatible across environments, native support for Module Workers in Node 12.8+, use of DOM-style events (`Event.data`, `Event.type`), support for event handler properties (`worker.onmessage`), and acceptance of module, Blob, or Data URLs. It also emulates `WorkerGlobalScope` within the worker context, offering a familiar environment for developers.
Traffic · last 30 days ↓100% vs prev 7d
top countries 🇺🇸 United States · 🇨🇦 Canada · 🇩🇪 Germany