JSON, etc), there are a variety of functions available from the DOM to workers. This article provides a list of those.
Workers run in a different global context than the current window! While
Window is not directly available to workers, many of the same methods are defined in a shared mixin (
WindowOrWorkerGlobalScope), and made available to workers through their own
DedicatedWorkerGlobalScopefor dedicated workers
SharedWorkerGlobalScopefor shared workers
ServiceWorkerGlobalScopefor service workers
The following functions are only available to workers:
DedicatedWorkerGlobalScope.postMessage(dedicated workers only).
Note: If a listed API is supported by a platform in a particular version, then it can generally be assumed to work in web workers.
The following Web APIs are available to workers:
Broadcast Channel API,
Channel Messaging API,
Data Store (Firefox only),
FileReaderSync (only works in workers!),
IndexedDB, Network Information API,
Promise, Server-sent events,
URL, WebGL with
OffscreenCanvas (enabled behind a feature preference setting
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.