Worklets are extension points for rendering engines. Conceptually, they're similar to Web Workers, but with a few key exceptions:

Worklets are JavaScript modules, added by invoking the worklet's addModule function, which is a Promise.

// From May 8, 2018 Editor's Draft

// From inside the browser's context
await demoWorklet.addModule('path/to/script.js');

// Multiple worklets can be loaded at once, as well
]).then(results => {
  // Both worklets have loaded, and we can do tasks that rely on them

The shape of a worklet file are all the same as well; a global scope registration function that takes the name of the item to be registered and the shape of the class for that particular worklet

// From May 8, 2018 Editor's Draft

// The kind of worklet it is
registerDemoWorklet('name', class { // The name we'll call this worklet

  // Each worklet can define different functions to be used
  // These will be called by the render engine as needed
  process(arg) {
    // Stuff happens in here! What happens depends on the worklet
    // Sometimes it'll return something
    // Other times it'll work directly on the arguments
    return !arg;

Worklet Lifecycle

Artboard 1 worklet.addModule process,
  1. The Worklet lifecycle starts from within the render engine
  2. For JavaScript, the render engine spins up its main JavaScript thread
  3. It then will spin up multiple worklet processes that worklets can live. These processes ideally are separate threads from the main thread, as to not block the main thread (but they don't need to be)
  4. The main thread then has our Browser JavaScript loaded in to it
  5. That JavaScript calls worklet.addModule to asynchronously load a worklet
  6. Once fetched, the worklet is loaded in to two or more of the available worklet processes
  7. When needed, the render engine will execute the worklet by calling the appropriate process function(s) from the loaded worklet. This call can be to any of the parallelized worklet instances