← Back to release summary

ES Modules for shared workers ('module' type option)

Category
JavaScript
Type
New or changed feature
Status
Enabled by default (Chrome 83)
Intent stage
Prepare to ship

WPT details: Fully tested. Web platform tests for module script loading in shared workers can be found in wpt/workers/modules directory. You can see the test result from wpt.fyi. Also we have web-platform-tests here as well: content-security-policy, referrer-policy, mixed-content, upgrade-insecure-request. SharedWorker cannot be nested nor called from Dedicated Workers, so there are no tests for constructing SharedWorker from workers.

Summary

JavaScript will support modules in shared workers. Setting 'module' type by the constructor's type attribute, worker scripts are loaded as ES modules and the import statement is available on worker contexts.

Motivation

With this feature, web developers can more easily write programs in a composable way and share them among a page and workers.

Standards & signals

Ecosystem

Docs: https://docs.google.com/document/d/1sSdYdSOLd5zvnNGeVNlBqfTZs_VRPIrrigV3SlMnWjg/edit?usp=sharing

Explainers: https://html.spec.whatwg.org/multipage/workers.html#shared-workers-and-the-sharedworker-interface

View on chromestatus.com