Worker.terminate()

The terminate() method of the Worker interface immediately terminates the Worker. This does not offer the worker an opportunity to finish its operations; it is simply stopped at once.

Syntax

JavaScript
myWorker.terminate();

Parameters

None.

Returns

Void.

Example

The following code snippet shows creation of a Worker object using the Worker() constructor, which is then immediately terminated.

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

myWorker.terminate();

Specifications

Specification Status Comment
WHATWG HTML Living Standard
The definition of 'Worker.postMessage()' in that specification.
Living Standard No change from Web Workers.
Web Workers
The definition of 'Worker.postMessage()' in that specification.
Candidate Recommendation Initial definition.

Browser compatibility

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

The Worker interface it belongs to.

License

© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/api/worker/terminate

API Method Reference Référence terminate Web Workers Worker