The Worker() constructor creates a dedicated Worker that runs a classic script or module at a given URL on a background thread(MDN). Use new Worker(url) or new Worker(url, options).
Pass the required arguments shown below. Always terminate unused workers; listen for error/messageerror as well as message.
Syntax
Create a Worker. Start with this line.
JavaScript
new Worker(url) / new Worker(url, options)
Call
What it does
new Worker(url) / new Worker(url, options)
Primary signature.
Built into the browser. Call new Worker(url, options) — no import required.
Library declarations
JavaScript
new Worker(url) / new Worker(url, options)
Parameters
Parameter
Description
url
Required. Script / module the worker runs
options.type
Optional. "classic" (default) or "module"
options.name
Optional. Debug name → self.name
Return Value
Return Value
Description
*
A Worker instance
JavaScript Examples
Example 1 — Basic Blob Worker
Create a classic worker from a blob URL and echo a message.
Compute off-thread. Worker multiplies and posts 42 back.
Why workers. Heavy work can stay off the UI thread.
Compatibility
Browser Support
Worker() is marked Baseline Widely available on MDN (since July 2015). Some options may have varying support. Available in Web Workers except Service Workers — not in Node.js, Bun, or Deno (use worker_threads there).
✓ Baseline · Widely available
Worker()
Create dedicated workers across modern browsers. Use same-origin scripts or blob: URLs for demos.
98%Browser support
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
Android WebViewSupported · Modern WebView
Full support
Worker()Excellent
Bottom line: Safe for everyday dedicated workers. Check MDN if you rely on module workers, credentials, or Trusted Types.
Frequently Asked Questions
new Worker(url, options) creates a dedicated Worker that runs a classic script or module at the given URL on a background thread, separate from the main page UI thread.
No. MDN marks the Worker() constructor as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard. Some options may have varying support. It is available in Web Workers except Service Workers.
A same-origin script URL (resolved relative to the HTML page), or a blob: or data: URL. Cross-origin worker scripts usually need an intermediate same-origin worker or a blob loaded after a CORS fetch.
type: "classic" (default) runs a classic script and can use importScripts(). type: "module" runs an ES module with import, CORS fetching, and strict mode.
In a single HTML file you often have no separate worker.js. Building a Blob of JavaScript and passing URL.createObjectURL(blob) creates a same-origin worker URL you can start immediately. Prefer blob: over data: when possible.
Yes if the URL comes from untrusted input—the script is executed (an injection sink / XSS risk). Prefer fixed same-origin scripts, CSP worker-src, and TrustedScriptURL when enforcing Trusted Types.