Worker interface represents a background task that can be easily created and can send messages back to their creators. Creating a worker is as simple as calling the
Worker() constructor, specifying a script to be run in the worker thread.
Of note is the fact that 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 exception that the
channel attributes on
XMLHttpRequest always return
Not all interfaces and functions are available to the script associated with a
Inherits properties from its parent,
EventListenerthat is called whenever a
messagebubbles through the worker. The message is stored in the event's
- Creates a dedicated web worker that executes the script at the specified URL.
Inherits methods from its parent,
Sends a message, that is
- Immediately terminates the worker. This does not offer the worker an opportunity to finish its operations; it is simply stopped at once.
|WHATWG HTML Living Standard||Living Standard||No change from Web Workers.|
|Web Workers||Candidate Recommendation||Initial definition.|
|Feature||Chrome||Firefox (Gecko)||Internet Explorer||Opera||Safari (WebKit)|
|Feature||Android||Firefox Mobile (Gecko)||IE Phone||Opera Mobile||Safari Mobile|