We're looking for a person or people to help audit MDN to find places we could speed up. Is this you or someone you know? Check out the RFP: https://mzl.la/2IHcMiE

Deze vertaling is niet volledig. Help dit artikel te vertalen vanuit het Engels.

The Worker interface of the Web Workers API represents a background task that can be easily created and can send messages back to its creator. Creating a worker is as simple as calling the Worker() constructor and specifying a script to be run in the worker thread.

Workers may in turn spawn new workers as long as those workers are hosted within the same origin as the parent page.  In addition workers may use XMLHttpRequest for network I/O, with the stipulation that the responseXML and channel attributes on XMLHttpRequest always return null.

Not all interfaces and functions are available to the script associated with a Worker.

In Firefox, if you want to use workers in extensions and would like to have access to js-ctypes, you should use the ChromeWorker object instead.


Inherits properties from its parent, EventTarget, and implements properties from AbstractWorker.

Event handlers

An EventListener called whenever an ErrorEvent of type error bubbles through to the worker. This is inherited from AbstractWorker.
An EventListener called whenever a MessageEvent of type message bubbles through the worker — i.e. when a message is sent to the parent document from the worker via DedicatedWorkerGlobalScope.postMessage. The message is stored in the event's data property.


Creates a dedicated web worker that executes the script at the specified URL. Workers can also be constructed using Blobs.


Inherits methods from its parent, EventTarget, and implements properties from AbstractWorker.

Sends a message — which can consist of any JavaScript object — to the worker's inner scope.
Immediately terminates the worker. This does not offer the worker an opportunity to finish its operations; it is simply stopped at once.


The following code snippet shows creation of a Worker object using the Worker() constructor and usage of the object:

var myWorker = new Worker("worker.js");

first.onchange = function() {
  console.log('Message posted to worker');

For a full example, see ourBasic dedicated worker example (run dedicated worker).


Specification Status Comment
HTML Living Standard
The definition of 'Worker' in that specification.
Living Standard No change from Unknown.
The definition of 'Worker' in that specification.
Unknown Initial definition.

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 4 3.5 10.0 10.6 4
Feature Android Firefox Mobile (Gecko) Firefox OS (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support 4.4 3.5 1.0.1 10.0 11.5 5.1

See also

Documentlabels en -medewerkers

 Aan deze pagina hebben bijgedragen: teoli
 Laatst bijgewerkt door: teoli,