Worklet

This is an experimental technology
Check 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 defining how custom CSS properties are being rendered, accessible 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 1
The definition of 'Worklet' in that specification.
Working Draft  

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Basic support
Experimental
Chrome Full support 65Edge No support NoFirefox Full support YesIE No support NoOpera Full support 52Safari No support NoWebView Android Full support 65Chrome Android Full support 65Edge Mobile No support NoFirefox Android Full support YesOpera Android Full support 52Safari iOS No support NoSamsung Internet Android Full support Yes
addModule
Experimental
Chrome Full support 65Edge No support NoFirefox Full support 63IE No support NoOpera Full support 52Safari No support NoWebView Android Full support 65Chrome Android Full support 65Edge Mobile No support NoFirefox Android Full support 63Opera Android Full support 52Safari iOS No support NoSamsung Internet Android Full support Yes

Legend

Full support  
Full support
No support  
No support
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.

See also

Document Tags and Contributors

Contributors to this page: ExE-Boss, heimeii, Jedipedia
Last updated by: ExE-Boss,