Web/API/Worklet

From Get docs

This is an experimental technologyCheck the Browser compatibility table carefully before using this in production.


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.

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
PaintWorklet For programmatically generating an image where a CSS property expects a file. Access this interface through CSS.paintWorklet. Chrome: Main thread

Gecko: Paint thread

CSS Painting API
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

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.

Properties

The Worklet interface does not define any properties.

Methods

Worklet.addModule() '
Adds the script module at the given URL to the current worklet.

Specifications

Specification Status Comment
Worklets Level 1The definition of 'Worklet' in that specification. Working Draft

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
Worklet Chrome

Full support 65

Edge

Full support 79

Firefox

Full support 76

IE

No support No

Opera

Full support 52

Safari

No support No

WebView Android

Full support 65

Chrome Android

Full support 65

Firefox Android

Full support 79

Opera Android

Full support 47

Safari iOS

No support No

Samsung Internet Android

Full support 9.0

addModule Chrome

Full support 65

Edge

Full support 79

Firefox

Full support 76

IE

No support No

Opera

Full support 52

Safari

No support No

WebView Android

Full support 65

Chrome Android

Full support 65

Firefox Android

Full support 79

Opera Android

Full support 47

Safari iOS

No support No

Samsung Internet Android

Full support 9.0

Legend

Full support  
Full support
No support  
No support


See also

Worklet by Mozilla Contributors is licensed under CC-BY-SA 2.5.