Worklets
The Worklet is a new concept introduced in Houdini. It is the most important thing that will enable developers to use the Houdini APIs in their work. Worklets are small Javascript classes in which you, the web-developer, put your code that is to be executed by the APIs. Worklets, in each of APIs, have specific signatures that allow them to hook at a low-level right into the browser's rendering engine. They run your custom rendering codes at very high speeds, same as that of the rendering processes.

Although Worklets use the same ES6 classes to define the collect of methods as the Workers, they are quite different in what they can do and how they are handled by the browser.

The Workers are run by the browser at a higher level and are relatively heavy-weight. These were not designed to run in large numbers. Houdini Worklets, on the other hand, run at the low-level in the rendering engine. Worklets are designed to be fast with a small or negligible footprint. Several instances of a worklet can be run in parallel. They have little or no impact on the responsiveness of the browser.

Worklets have an isolated scope and a very small API surface allowing the browsers to better optimize their execution.

Some noteworthy characteristics of the Worklet are...
  • The worklets are used by web-developers to run their custom routines in the rendering engine.
  • The worklets use the ES6 classes to define a collection of methods.
  • The signatures of the worklet are predefined by the type of the worklet for eg paintWorklet, animationWorklet, layoutWorklet etc.
  • The worklets are light-weight and short lived.
  • They are thread-agnostic - that is they are not defined to run on a particular thread. The browser decides when a worklet will be run and in which thread.
  • The worklets have an isolated scope, i.e. no access to the global objects like - window, document etc, or high-level functions like alert etc.