Functions and classes available to Web Workers
Web Workers API
Web Workers API
In addition to the standard JavaScript set of functions (such as String, Array, Object, JSON, etc.), there are a variety of functions (and APIs) available in the workers. This article provides a list of those.
Functions available in workers
The following functions are available to workers:
- WorkerGlobalScope.atob()
- WorkerGlobalScope.btoa()
- WorkerGlobalScope.clearInterval()
- WorkerGlobalScope.clearTimeout()
- WorkerGlobalScope.createImageBitmap()
- WorkerGlobalScope.dump()
- WorkerGlobalScope.fetch()
- WorkerGlobalScope.queueMicrotask()
- WorkerGlobalScope.reportError()
- WorkerGlobalScope.setInterval()
- WorkerGlobalScope.setTimeout()
- WorkerGlobalScope.structuredClone()
- DedicatedWorkerGlobalScope.postMessage() (dedicated workers only)
- DedicatedWorkerGlobalScope.requestAnimationFrame() (dedicated workers only)
- DedicatedWorkerGlobalScope.cancelAnimationFrame() (dedicated workers only)
The following functions are only available to workers:
- WorkerGlobalScope.importScripts()
Web APIs available in workers
[!NOTE] If a listed API is supported by a platform in a particular version, then it can generally be assumed to be available in web workers. You can test support for a particular object or function using the Worker Playground.
The following Web APIs are available to workers:
-
-
-
-
-
- (service workers only)
- (excluding StylePropertyMap)
-
-
-
- (dedicated workers only)
-
-
-
-
-
-
-
-
-
-
- (dedicated and service workers only)
Workers can also spawn other workers, so these APIs are also available:
- Worker
- WorkerGlobalScope
- WorkerLocation
- WorkerNavigator
See also
- Using web workers
- Worker