WorkerGlobalScope

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

* Some parts of this feature may have varying levels of support.

Note: This feature is only available in Web Workers.

The WorkerGlobalScope interface of the Web Workers API is an interface representing the scope of any worker. Workers have no browsing context; this scope contains the information usually conveyed by Window objects — in this case event handlers, the console or the associated WorkerNavigator object. Each WorkerGlobalScope has its own event loop.

This interface is usually specialized by each worker type: DedicatedWorkerGlobalScope for dedicated workers, SharedWorkerGlobalScope for shared workers, and ServiceWorkerGlobalScope for ServiceWorker. The self property returns the specialized scope for each context.

EventTarget WorkerGlobalScope

Instance properties

This interface inherits properties from the EventTarget interface.

WorkerGlobalScope.caches Read only Secure context

Returns the CacheStorage object associated with the current context. This object enables functionality such as storing assets for offline use, and generating custom responses to requests.

WorkerGlobalScope.crossOriginIsolated Read only

Returns a boolean value that indicates whether the website is in a cross-origin isolation state.

WorkerGlobalScope.crypto Read only

Returns the Crypto object associated to the global object.

WorkerGlobalScope.fonts Read only

Returns the FontFaceSet associated with the worker.

WorkerGlobalScope.indexedDB Read only

Provides a mechanism for workers to asynchronously access capabilities of indexed databases; returns an IDBFactory object.

WorkerGlobalScope.isSecureContext Read only

Returns a boolean indicating whether the current context is secure (true) or not (false).

WorkerGlobalScope.location Read only

Returns the WorkerLocation associated with the worker. It is a specific location object, mostly a subset of the Location for browsing scopes, but adapted to workers.

WorkerGlobalScope.navigator Read only

Returns the WorkerNavigator associated with the worker. It is a specific navigator object, mostly a subset of the Navigator for browsing scopes, but adapted to workers.

WorkerGlobalScope.origin Read only

Returns the global object's origin, serialized as a string.

WorkerGlobalScope.performance Read only

Returns the Performance associated with the worker. Only a subset of the properties and methods of the Performance interface are available to workers.

WorkerGlobalScope.scheduler Read only

Returns the Scheduler object associated with the current context. This is the entry point for using the Prioritized Task Scheduling API.

WorkerGlobalScope.trustedTypes Read only

Returns the TrustedTypePolicyFactory object associated with the global object, providing the entry point for using the Trusted Types API.

WorkerGlobalScope.self Read only

Returns a reference to the WorkerGlobalScope itself. Most of the time it is a specific scope like DedicatedWorkerGlobalScope, SharedWorkerGlobalScope or ServiceWorkerGlobalScope.

Instance methods

This interface inherits methods from the EventTarget interface.

WorkerGlobalScope.atob()

Decodes a string of data which has been encoded using base-64 encoding.

WorkerGlobalScope.btoa()

Creates a base-64 encoded ASCII string from a string of binary data.

WorkerGlobalScope.clearInterval()

Cancels the repeated execution set using WorkerGlobalScope.setInterval().

WorkerGlobalScope.clearTimeout()

Cancels the delayed execution set using WorkerGlobalScope.setTimeout().

WorkerGlobalScope.createImageBitmap()

Accepts a variety of different image sources, and returns a Promise which resolves to an ImageBitmap. Optionally the source is cropped to the rectangle of pixels originating at (sx, sy) with width sw, and height sh.

WorkerGlobalScope.dump()

Allows you to write a message to stdout — i.e., in your terminal. This is the same as Firefox's window.dump, but for workers.

WorkerGlobalScope.fetch()

Starts the process of fetching a resource from the network.

WorkerGlobalScope.importScripts()

Imports one or more scripts into the worker's scope. You can specify as many as you'd like, separated by commas. For example: importScripts('foo.js', 'bar.js');.

WorkerGlobalScope.queueMicrotask()

Queues a microtask to be executed at a safe time prior to control returning to the browser's event loop.

WorkerGlobalScope.setInterval()

Schedules a function to execute every time a given number of milliseconds elapses.

WorkerGlobalScope.setTimeout()

Schedules a function to execute in a given amount of time.

WorkerGlobalScope.structuredClone()

Creates a deep clone of a given value using the structured clone algorithm.

WorkerGlobalScope.reportError()

Reports an error in a script, emulating an unhandled exception.

Events

error

Fired when an error occurred.

languagechange

Fired at the global/worker scope object when the user's preferred languages change.

offline

Fired when the browser has lost access to the network and the value of navigator.onLine switched to false.

online

Fired when the browser has gained access to the network and the value of navigator.onLine switched to true.

rejectionhandled

Fired on handled Promise rejection events.

securitypolicyviolation

Fired when a Content Security Policy is violated.

unhandledrejection

Fired on unhandled Promise rejection events.

Example

You won't access WorkerGlobalScope directly in your code; however, its properties and methods are inherited by more specific global scopes such as DedicatedWorkerGlobalScope and SharedWorkerGlobalScope. For example, you could import another script into the worker and print out the contents of the worker scope's navigator object using the following two lines:

js
importScripts("foo.js");
console.log(navigator);

Note: Since the global scope of the worker script is effectively the global scope of the worker you are running (DedicatedWorkerGlobalScope or whatever) and all worker global scopes inherit methods, properties, etc. from WorkerGlobalScope, you can run lines such as those above without specifying a parent object.

Specifications

Specification
HTML
# the-workerglobalscope-common-interface

Browser compatibility

desktop mobile server
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
WorkerGlobalScope
Chrome – Full support
Chrome 4 (Release date: 2010-01-25)
footnote Full support
Edge – Full support
Edge 12 (Release date: 2015-07-29)
footnote Full support
Firefox – Full support
Firefox 3.5 (Release date: 2009-06-30)
footnote Full support
Opera – Full support
Opera 10.6 (Release date: 2010-07-01)
footnote Full support
Safari – Full support
Safari 4 (Release date: 2009-06-08)
footnote Full support
Chrome Android – Full support
Chrome Android 18 (Release date: 2012-06-27)
footnote Full support
Firefox for Android – Full support
Firefox for Android 4 (Release date: 2011-03-29)
footnote Full support
Opera Android – Full support
Opera Android 11 (Release date: 2011-03-22)
footnote Full support
Safari on iOS – Full support
Safari on iOS 5 (Release date: 2011-10-12)
footnote Full support
Samsung Internet – Full support
Samsung Internet 1 (Release date: 2013-04-27)
footnote Full support
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
footnote Full support
WebView on iOS – Full support
WebView on iOS 5 (Release date: 2011-10-12)
footnote Full support
Deno – Full support
Deno 1 (Release date: 2020-05-13)
footnote Full support
dump
Deprecated Non-standard
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – Partial support
Firefox 3.5 (Release date: 2009-06-30)
footnote Partial support
footnote This method exists but has no effect.
Opera – No support
Opera
footnote No support
Safari – No support
Safari
footnote No support
Chrome Android – No support
Chrome Android
footnote No support
Firefox for Android – Partial support
Firefox for Android 4 (Release date: 2011-03-29)
footnote Partial support
footnote This method exists but has no effect.
Opera Android – No support
Opera Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – No support
WebView on iOS
footnote No support
Deno – No support
Deno
footnote No support
error event
Chrome – Full support
Chrome 4 (Release date: 2010-01-25)
footnote Full support
Edge – Full support
Edge 12 (Release date: 2015-07-29)
footnote Full support
Firefox – Full support
Firefox 3.5 (Release date: 2009-06-30)
footnote Full support
Opera – Full support
Opera 11.5 (Release date: 2011-06-28)
footnote Full support
Safari – Full support
Safari 4 (Release date: 2009-06-08)
footnote Full support
Chrome Android – Full support
Chrome Android 18 (Release date: 2012-06-27)
footnote Full support
Firefox for Android – Full support
Firefox for Android 4 (Release date: 2011-03-29)
footnote Full support
Opera Android – Full support
Opera Android 14 (Release date: 2013-05-21)
footnote Full support
Safari on iOS – Full support
Safari on iOS 5 (Release date: 2011-10-12)
footnote Full support
Samsung Internet – Full support
Samsung Internet 1 (Release date: 2013-04-27)
footnote Full support
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
footnote Full support
WebView on iOS – Full support
WebView on iOS 5 (Release date: 2011-10-12)
footnote Full support
Deno – Full support
Deno 1 (Release date: 2020-05-13)
footnote Full support
fonts
Chrome – Full support
Chrome 69 (Release date: 2018-09-04)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 105 (Release date: 2022-09-20)
footnote Full support
Opera – Full support
Opera 56 (Release date: 2018-09-25)
footnote Full support
Safari – Full support
Safari 15 (Release date: 2021-09-20)
footnote Full support
Chrome Android – Full support
Chrome Android 69 (Release date: 2018-09-04)
footnote Full support
Firefox for Android – Full support
Firefox for Android 105 (Release date: 2022-09-20)
footnote Full support
Opera Android – Full support
Opera Android 48 (Release date: 2018-11-08)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
Samsung Internet – Full support
Samsung Internet 10 (Release date: 2019-08-22)
footnote Full support
WebView Android – Full support
WebView Android 69 (Release date: 2018-09-04)
footnote Full support
WebView on iOS – Full support
WebView on iOS 15 (Release date: 2021-09-20)
footnote Full support
Deno – No support
Deno
footnote No support
importScripts
Chrome – Full support
Chrome 4 (Release date: 2010-01-25)
footnote Full support
Edge – Full support
Edge 12 (Release date: 2015-07-29)
footnote Full support
Firefox – Full support
Firefox 4 (Release date: 2011-03-22)
footnote Full support
Opera – Full support
Opera 10.6 (Release date: 2010-07-01)
footnote Full support
Safari – Full support
Safari 4 (Release date: 2009-06-08)
footnote Full support
Chrome Android – Full support
Chrome Android 18 (Release date: 2012-06-27)
footnote Full support
Firefox for Android – Full support
Firefox for Android 4 (Release date: 2011-03-29)
footnote Full support
Opera Android – Full support
Opera Android 11 (Release date: 2011-03-22)
footnote Full support
Safari on iOS – Full support
Safari on iOS 5 (Release date: 2011-10-12)
footnote Full support
Samsung Internet – Full support
Samsung Internet 1 (Release date: 2013-04-27)
footnote Full support
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
footnote Full support
WebView on iOS – Full support
WebView on iOS 5 (Release date: 2011-10-12)
footnote Full support
Deno – No support
Deno
footnote No support
urls parameter requires TrustedScriptURL instances when trusted types are enforced
Chrome – Full support
Chrome 138 (Release date: 2025-06-24)
footnote Full support
Edge – Full support
Edge 138 (Release date: 2025-06-26)
footnote Full support
Firefox – Preview support
Firefox Nightly
footnote Preview browser support
Opera – Full support
Opera 122 (Release date: 2025-09-11)
footnote Full support
Safari – Full support
Safari 26 (Release date: 2025-09-15)
footnote Full support
Chrome Android – Full support
Chrome Android 138 (Release date: 2025-06-24)
footnote Full support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – Full support
Opera Android 91 (Release date: 2025-08-19)
footnote Full support
Safari on iOS – Full support
Safari on iOS 26 (Release date: 2025-09-15)
footnote Full support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – Full support
WebView Android 138 (Release date: 2025-06-24)
footnote Full support
WebView on iOS – Full support
WebView on iOS 26 (Release date: 2025-09-15)
footnote Full support
Deno – No support
Deno
footnote No support
Strict MIME type checks for importScripts()
Chrome – Full support
Chrome 71 (Release date: 2018-12-04)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 67 (Release date: 2019-05-21)
footnote Full support
Opera – Full support
Opera 58 (Release date: 2019-01-23)
footnote Full support
Safari – Full support
Safari 16 (Release date: 2022-09-12)
footnote Full support
Chrome Android – Full support
Chrome Android 71 (Release date: 2018-12-04)
footnote Full support
Firefox for Android – Full support
Firefox for Android 67 (Release date: 2019-05-21)
footnote Full support
Opera Android – Full support
Opera Android 50 (Release date: 2019-02-18)
footnote Full support
Safari on iOS – Full support
Safari on iOS 16 (Release date: 2022-09-12)
footnote Full support
Samsung Internet – Full support
Samsung Internet 10 (Release date: 2019-08-22)
footnote Full support
WebView Android – Full support
WebView Android 71 (Release date: 2018-12-04)
footnote Full support
WebView on iOS – Full support
WebView on iOS 16 (Release date: 2022-09-12)
footnote Full support
Deno – No support
Deno
footnote No support
languagechange event
Chrome – Full support
Chrome 4 (Release date: 2010-01-25)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 74 (Release date: 2020-03-10)
footnote Full support
Opera – Full support
Opera 11.5 (Release date: 2011-06-28)
footnote Full support
Safari – No support
Safari
footnote No support
Chrome Android – Full support
Chrome Android 18 (Release date: 2012-06-27)
footnote Full support
Firefox for Android – Full support
Firefox for Android 79 (Release date: 2020-07-28)
footnote Full support
Opera Android – Full support
Opera Android 14 (Release date: 2013-05-21)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – Full support
Samsung Internet 1 (Release date: 2013-04-27)
footnote Full support
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote No support
Deno – No support
Deno
footnote No support
location
Chrome – Full support
Chrome 4 (Release date: 2010-01-25)
footnote Full support
Edge – Full support
Edge 12 (Release date: 2015-07-29)
footnote Full support
Firefox – Full support
Firefox 3.5 (Release date: 2009-06-30)
footnote Full support
Opera – Full support
Opera 11.5 (Release date: 2011-06-28)
footnote Full support
Safari – Full support
Safari 4 (Release date: 2009-06-08)
footnote Full support
Chrome Android – Full support
Chrome Android 18 (Release date: 2012-06-27)
footnote Full support
Firefox for Android – Full support
Firefox for Android 4 (Release date: 2011-03-29)
footnote Full support
Opera Android – Full support
Opera Android 14 (Release date: 2013-05-21)
footnote Full support
Safari on iOS – Full support
Safari on iOS 5 (Release date: 2011-10-12)
footnote Full support
Samsung Internet – Full support
Samsung Internet 1 (Release date: 2013-04-27)
footnote Full support
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
footnote Full support
WebView on iOS – Full support
WebView on iOS 5 (Release date: 2011-10-12)
footnote Full support
Deno – Full support
Deno 1.7 (Release date: 2021-01-19)
footnote Full support
navigator
Chrome – Full support
Chrome 4 (Release date: 2010-01-25)
footnote Full support
Edge – Full support
Edge 17 (Release date: 2018-04-30)
footnote Full support
Firefox – Full support
Firefox 3.5 (Release date: 2009-06-30)
footnote Full support
Opera – Full support
Opera 11.5 (Release date: 2011-06-28)
footnote Full support
Safari – Full support
Safari 4 (Release date: 2009-06-08)
footnote Full support
Chrome Android – Full support
Chrome Android 18 (Release date: 2012-06-27)
footnote Full support
Firefox for Android – Full support
Firefox for Android 4 (Release date: 2011-03-29)
footnote Full support
Opera Android – Full support
Opera Android 14 (Release date: 2013-05-21)
footnote Full support
Safari on iOS – Full support
Safari on iOS 5 (Release date: 2011-10-12)
footnote Full support
Samsung Internet – Full support
Samsung Internet 1 (Release date: 2013-04-27)
footnote Full support
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
footnote Full support
WebView on iOS – Full support
WebView on iOS 5 (Release date: 2011-10-12)
footnote Full support
Deno – Full support
Deno 1.8 (Release date: 2021-03-02)
footnote Full support
offline event
Chrome – No support
Chrome
footnote
footnote See bug 40155587
Edge – No support
Edge
footnote
footnote See bug 40155587
Firefox – Full support
Firefox 29 (Release date: 2014-04-29)
footnote Full support
Opera – No support
Opera
footnote
footnote See bug 40155587
Safari – Full support
Safari 8 (Release date: 2014-10-16)
footnote Full support
Chrome Android – No support
Chrome Android
footnote
footnote See bug 40155587
Firefox for Android – Full support
Firefox for Android 29 (Release date: 2014-04-29)
footnote Full support
Opera Android – No support
Opera Android
footnote
footnote See bug 40155587
Safari on iOS – Full support
Safari on iOS 8 (Release date: 2014-09-17)
footnote Full support
Samsung Internet – No support
Samsung Internet
footnote
footnote See bug 40155587
WebView Android – No support
WebView Android
footnote
footnote See bug 40155587
WebView on iOS – Full support
WebView on iOS 8 (Release date: 2014-09-17)
footnote Full support
Deno – No support
Deno
footnote No support
online event
Chrome – No support
Chrome
footnote
footnote See bug 40155587
Edge – No support
Edge
footnote
footnote See bug 40155587
Firefox – Full support
Firefox 29 (Release date: 2014-04-29)
footnote Full support
Opera – No support
Opera
footnote
footnote See bug 40155587
Safari – Full support
Safari 8 (Release date: 2014-10-16)
footnote Full support
Chrome Android – No support
Chrome Android
footnote
footnote See bug 40155587
Firefox for Android – Full support
Firefox for Android 29 (Release date: 2014-04-29)
footnote Full support
Opera Android – No support
Opera Android
footnote
footnote See bug 40155587
Safari on iOS – Full support
Safari on iOS 8 (Release date: 2014-09-17)
footnote Full support
Samsung Internet – No support
Samsung Internet
footnote
footnote See bug 40155587
WebView Android – No support
WebView Android
footnote
footnote See bug 40155587
WebView on iOS – Full support
WebView on iOS 8 (Release date: 2014-09-17)
footnote Full support
Deno – No support
Deno
footnote No support
rejectionhandled event
Chrome – Full support
Chrome 49 (Release date: 2016-03-02)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 69 (Release date: 2019-09-03)
footnote Full support
Opera – Full support
Opera 36 (Release date: 2016-03-15)
footnote Full support
Safari – Full support
Safari 11 (Release date: 2017-09-19)
footnote Full support
Chrome Android – Full support
Chrome Android 49 (Release date: 2016-03-09)
footnote Full support
Firefox for Android – Full support
Firefox for Android 79 (Release date: 2020-07-28)
footnote Full support
Opera Android – Full support
Opera Android 36 (Release date: 2016-03-31)
footnote Full support
Safari on iOS – Full support
Safari on iOS 11 (Release date: 2017-09-19)
footnote Full support
Samsung Internet – Full support
Samsung Internet 5 (Release date: 2016-12-15)
footnote Full support
WebView Android – Full support
WebView Android 49 (Release date: 2016-03-09)
footnote Full support
WebView on iOS – Full support
WebView on iOS 11 (Release date: 2017-09-19)
footnote Full support
Deno – No support
Deno
footnote No support
securitypolicyviolation event
Chrome – Full support
Chrome 41 (Release date: 2015-03-03)
footnote Full support
Edge – Full support
Edge 15 (Release date: 2017-04-05)
footnote Full support
Firefox – Full support
Firefox 63 (Release date: 2018-10-23)
footnote Full support
Opera – Full support
Opera 28 (Release date: 2015-03-10)
footnote Full support
Safari – Full support
Safari 10 (Release date: 2016-09-20)
footnote Full support
Chrome Android – Full support
Chrome Android 41 (Release date: 2015-03-11)
footnote Full support
Firefox for Android – Full support
Firefox for Android 63 (Release date: 2018-10-23)
footnote Full support
Opera Android – Full support
Opera Android 28 (Release date: 2015-03-10)
footnote Full support
Safari on iOS – Full support
Safari on iOS 10 (Release date: 2016-09-13)
footnote Full support
Samsung Internet – Full support
Samsung Internet 4 (Release date: 2016-03-11)
footnote Full support
WebView Android – Full support
WebView Android 41 (Release date: 2015-03-11)
footnote Full support
WebView on iOS – Full support
WebView on iOS 10 (Release date: 2016-09-13)
footnote Full support
Deno – No support
Deno
footnote No support
self
Chrome – Full support
Chrome 4 (Release date: 2010-01-25)
footnote Full support
Edge – Full support
Edge 12 (Release date: 2015-07-29)
footnote Full support
Firefox – Full support
Firefox 3.5 (Release date: 2009-06-30)
footnote Full support
Opera – Full support
Opera 11.5 (Release date: 2011-06-28)
footnote Full support
Safari – Full support
Safari 4 (Release date: 2009-06-08)
footnote Full support
Chrome Android – Full support
Chrome Android 18 (Release date: 2012-06-27)
footnote Full support
Firefox for Android – Full support
Firefox for Android 34 (Release date: 2014-12-01)
footnote Full support
Opera Android – Full support
Opera Android 14 (Release date: 2013-05-21)
footnote Full support
Safari on iOS – Full support
Safari on iOS 5 (Release date: 2011-10-12)
footnote Full support
Samsung Internet – Full support
Samsung Internet 1 (Release date: 2013-04-27)
footnote Full support
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
footnote Full support
WebView on iOS – Full support
WebView on iOS 5 (Release date: 2011-10-12)
footnote Full support
Deno – Full support
Deno 1 (Release date: 2020-05-13)
footnote Full support
unhandledrejection event
Chrome – Full support
Chrome 49 (Release date: 2016-03-02)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 69 (Release date: 2019-09-03)
footnote Full support
Opera – Full support
Opera 36 (Release date: 2016-03-15)
footnote Full support
Safari – Full support
Safari 11 (Release date: 2017-09-19)
footnote Full support
Chrome Android – Full support
Chrome Android 49 (Release date: 2016-03-09)
footnote Full support
Firefox for Android – Full support
Firefox for Android 79 (Release date: 2020-07-28)
footnote Full support
Opera Android – Full support
Opera Android 36 (Release date: 2016-03-31)
footnote Full support
Safari on iOS – Full support
Safari on iOS 11 (Release date: 2017-09-19)
footnote Full support
Samsung Internet – Full support
Samsung Internet 5 (Release date: 2016-12-15)
footnote Full support
WebView Android – Full support
WebView Android 49 (Release date: 2016-03-09)
footnote Full support
WebView on iOS – Full support
WebView on iOS 11 (Release date: 2017-09-19)
footnote Full support
Deno – No support
Deno
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
In development. Supported in a pre-release version.
In development. Supported in a pre-release version.
No support
No support
Non-standard. Check cross-browser support before using.
Deprecated. Not for use in new websites.
See implementation notes.

See also