Install

Works with Drupal: ^11 || ^12

Using Composer to manage Drupal site dependencies

Alternative installation files

Download tar.gz 82.11 KB
MD5: 81fc20ae6d7f894fd8533e72d0d84bf1
SHA-1: 79188d3ad81b1d3a4d53345416e0e1f5df3a1011
SHA-256: 68f5df431513b33bce98c2bc366b892ad0cf72b856c4f2561d5776ddc6349860
Download zip 158.33 KB
MD5: ca67cdacd96307757a164d9c5d0ad7fb
SHA-1: b39df0d28d5e4c9711918845d4b97b6b0c218c40
SHA-256: e0648f1aa884c0fa8207636fb210817b045b914e9a2593fe7e27550123b4336a

Release notes

Web Component Runtime 1.1.0 adds three features that registered web component libraries can opt into, plus one that's on by default. Every new registry field is optional, so libraries registered for 1.0.0 keep working unchanged.

New features

  • Lazy element loading (#3627756). A library that sets loader: lazy and a tags map has each element's module imported the first time its tag appears on the page, including in hand-written markup, AJAX responses and content Canvas re-renders, none of which attach the library. While a library is lazy, every HTML page gets its import map entries and a small loader; pages are unchanged while no library is.
  • Base path handover (#3627757). Libraries that load their own assets, such as icons, from a base path can have the runtime hand it to them with the new base_path_api field: { attribute: data-… } sets an attribute on the import map's <script type="importmap"> for Shoelace-style libraries, and { module: …, export: … } calls an exported setter, such as Stencil's setAssetPath(), before the library's own scripts run. It works for libraries loaded lazily and for ones an AJAX response brings in.
  • Hiding undefined elements (#3627758). A registered library's elements are hidden until they're defined, so they no longer flash unstyled. A small script in <head> finds them by the library's tag prefix as the page is parsed and as content is added, so no list of tags is needed. A tag that's still undefined after 3 seconds is shown anyway, with a console warning naming it.
  • Color scheme switching (#3627758). The runtime now acts on color_scheme: it puts the library's dark or light class on <html> before the page is first painted, following <html data-color-scheme> when it's pinned and the visitor's prefers-color-scheme otherwise.

Upgrading

  • Hiding is on by default. After updating, every registered library's undefined elements start hidden instead of flashing unstyled. A library opts out with hide_undefined: false in its registry file. Without JavaScript nothing is hidden.
  • Generated libraries keep working. Libraries generated by cem_sdc_generator that still ship cem-sdc-generator-color-scheme.js, such as cordwainer_elements 1.1.x and 1.2.x, behave the same with both scripts loaded. A future cem_sdc_generator release stops writing that script and requires this release.
  • A library that uses a new field (base_path_api or hide_undefined) should require drupal/web_component_runtime: ^1.1, since 1.0.0 rejects keys it doesn't know.
  • One validation change: loader: lazy without tags no longer leaves the library out. It's now logged as a registry error and the library is loaded by its Drupal library instead. A lazy library's tag module outside its scope is reported the same way and skipped.

Content Security Policy

With the Content-Security-Policy module, base path setter scripts carry the import map's nonce. The hiding rules live in a constructed stylesheet, which a policy doesn't restrict, so no style nonce is needed.

Requirements

Drupal 11 or 12. No new dependencies.

See the README's "Lazy loading", "Base paths" and "Undefined elements and color schemes" sections for details.

Created by: matthand
Created on: 24 Nov 2026 at 21:09 UTC
Last updated: 24 Nov 2026 at 21:10 UTC
New features

Other releases