Get to know MDN better
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 addModule() method of the Worklet interface loads the module in the given JavaScript file and adds it to the current Worklet.
A String containing the URL of a JavaScript file with the module to add.
options OptionalAn object with any of the following options:
credentialsA Request.credentials value that indicates whether to send credentials (e.g., cookies and HTTP authentication) when loading the module. Can be one of "omit", "same-origin", or "include". Defaults to "same-origin". See also Request.credentials.
A Promise that resolves once the module from the given URL has been added. The promise doesn't return any value.
If addModule() fails, it rejects the promise, delivering one of the following errors to the rejection handler.
AbortError DOMExceptionThe specified script is invalid or could not be loaded.
SyntaxError DOMExceptionThe specified moduleURL is invalid.
Once the script has been added to the paint worklet, the CSS paint() function can be used to include the image created by the worklet:
| HTML # dom-worklet-addmodule-dev |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Aug 5, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.