DedicatedWorkerGlobalScope.close()

The close() method of the DedicatedWorkerGlobalScope interface discards any tasks queued in the DedicatedWorkerGlobalScope's event loop, effectively closing this particular scope.

Syntax

self.close();

Example

If you want to close your worker instance from inside the worker itself, you can call the following:

close();

close() and self.close() are effectively equivalent — both represent close() being called from inside the worker's inner scope.

Note: There is also a way to stop the worker from the main thread: the Worker.terminate method.

Specifications

Specification Status Comment
HTML Living Standard
The definition of 'close()' in that specification.
Living Standard  

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome Full support YesEdge ? Firefox Full support 54IE ? Opera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android Full support 54Opera Android Full support YesSafari iOS ? Samsung Internet Android Full support Yes

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown

See also

DedicatedWorkerGlobalScope

Document Tags and Contributors

Contributors to this page: fscholz, chrisdavidmills
Last updated by: fscholz,