Worklet

Baseline Widely available

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

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The Worklet interface is a lightweight version of Web Workers and gives developers access to low-level parts of the rendering pipeline.

With Worklets, you can run JavaScript and WebAssembly code to do graphics rendering or audio processing where high performance is required.

Worklets allow static import of ECMAScript modules, if supported, using import. Dynamic import is disallowed by the specification — calling import() will throw.

Worklet types

Worklets are restricted to specific use cases; they cannot be used for arbitrary computations like Web Workers. The Worklet interface abstracts properties and methods common to all kind of worklets, and cannot be created directly. Instead, you can use one of the following classes:

Name Description Location Specification
AudioWorklet For audio processing with custom AudioNodes. Web Audio render thread Web Audio API
AnimationWorklet For creating scroll-linked and other high performance procedural animations. Compositor thread CSS Animation Worklet API
LayoutWorklet For defining the positioning and dimensions of custom elements. CSS Layout API
SharedStorageWorklet For running private operations on cross-site data, without risk of data leakage. Main thread Shared Storage API

Note: Paint worklets, defined by the CSS Painting API, don't subclass Worklet. They are accessed through a regular Worklet object obtained using CSS.paintWorklet.

For 3D rendering with WebGL, you don't use worklets. Instead, you write vertex shaders and fragment shaders using GLSL code, and those shaders will then run on the graphics card.

Instance properties

The Worklet interface does not define any properties.

Instance methods

Worklet.addModule()

Adds the script module at the given URL to the current worklet.

Specifications

Specification
HTML
# worklets-worklet

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Worklet
Chrome – Full support
Chrome 65 (Release date: 2018-03-06)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 76 (Release date: 2020-05-05)
footnote Full support
Opera – Full support
Opera 52 (Release date: 2018-03-22)
footnote Full support
Safari – Full support
Safari 14.1 (Release date: 2021-04-26)
footnote Full support
Chrome Android – Full support
Chrome Android 65 (Release date: 2018-03-06)
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 47 (Release date: 2018-07-23)
footnote Full support
Safari on iOS – Full support
Safari on iOS 14.5 (Release date: 2021-04-26)
footnote Full support
Samsung Internet – Full support
Samsung Internet 9 (Release date: 2018-09-15)
footnote Full support
WebView Android – Full support
WebView Android 65 (Release date: 2018-03-06)
footnote Full support
WebView on iOS – Full support
WebView on iOS 14.5 (Release date: 2021-04-26)
footnote Full support
addModule
Chrome – Full support
Chrome 65 (Release date: 2018-03-06)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 76 (Release date: 2020-05-05)
footnote Full support
Opera – Full support
Opera 52 (Release date: 2018-03-22)
footnote Full support
Safari – Full support
Safari 14.1 (Release date: 2021-04-26)
footnote Full support
Chrome Android – Full support
Chrome Android 65 (Release date: 2018-03-06)
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 47 (Release date: 2018-07-23)
footnote Full support
Safari on iOS – Full support
Safari on iOS 14.5 (Release date: 2021-04-26)
footnote Full support
Samsung Internet – Full support
Samsung Internet 9 (Release date: 2018-09-15)
footnote Full support
WebView Android – Full support
WebView Android 65 (Release date: 2018-03-06)
footnote Full support
WebView on iOS – Full support
WebView on iOS 14.5 (Release date: 2021-04-26)
footnote Full support
Support for ECMAScript modules
Chrome – Full support
Chrome 80 (Release date: 2020-02-04)
footnote Full support
Edge – Full support
Edge 80 (Release date: 2020-02-07)
footnote Full support
Firefox – Full support
Firefox 114 (Release date: 2023-06-06)
footnote Full support
Opera – Full support
Opera 67 (Release date: 2020-03-03)
footnote Full support
Safari – Full support
Safari 15 (Release date: 2021-09-20)
footnote
footnote Nested workers support was introduced in Safari 15.5.
footnote Script loading in nested workers was introduced in Safari 16.4.
Chrome Android – Full support
Chrome Android 80 (Release date: 2020-02-04)
footnote Full support
Firefox for Android – Full support
Firefox for Android 114 (Release date: 2023-06-06)
footnote Full support
Opera Android – Full support
Opera Android 57 (Release date: 2020-03-30)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote
footnote Nested workers support was introduced in Safari on iOS 15.5.
footnote Script loading in nested workers was introduced in Safari on iOS 16.4.
Samsung Internet – Full support
Samsung Internet 13 (Release date: 2020-12-02)
footnote Full support
WebView Android – Full support
WebView Android 80 (Release date: 2020-02-04)
footnote Full support
WebView on iOS – Full support
WebView on iOS 15 (Release date: 2021-09-20)
footnote
footnote Nested workers support was introduced in WebView on iOS 15.5.
footnote Script loading in nested workers was introduced in WebView on iOS 16.4.

Legend

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

Full support
Full support
See implementation notes.

See also