Style Module Imports via Link Elements
- Category
- DOM
- Type
- New or changed feature
- Status
- Proposed (Chrome Proposed)
- Intent stage
- None
Summary
Introduces a variation of `<link rel=stylesheet>` that utilizes the module map and shares CSSStyleSheet instances between shadow roots. Allows developers to use existing features available in Javascript (such as the module map and import maps) with declarative HTML.
Motivation
Without this feature, developers have several non-ideal options for sharing a set of styles between declarative shadow DOM hosts: 1. Use imperative CSS Modules, somewhat defeating the purpose of declarative shadow DOM, because it requires script and must happen after the declarative shadow DOM has been parsed. 2. Duplicating <style> tags, resulting in more work for parser and more work for the developer to update dynamically. 3. Use external CSS files in a <link> tag, resulting in a potential Flash of Unstyled Content (FOUC), as well as more work for the developer to update dynamically.
Standards & signals
- Firefox: No signal
- Safari: No signal
- Web developers: No signals
- Tracking bug: https://issues.chromium.org/issues/543937337
Ecosystem
- Web Platform Tests: https://wpt.fyi/results/?q=style-module-imports-via-link-elements
- Chrome Platform Showcase: https://chrome-platform-showcase.paulkinlan-ea.deno.net/features
- GenDN reference: https://gendn.paulkinlan-ea.deno.net/features
- chrome.dev demos search: https://www.google.com/search?q=site%3Achrome.dev+Style%20Module%20Imports%20via%20Link%20Elements
- MDN Web Docs: https://developer.mozilla.org/en-US/search?q=Style%20Module%20Imports%20via%20Link%20Elements
- Baseline status: https://webstatus.dev/?q=Style%20Module%20Imports%20via%20Link%20Elements
Explainers: https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/main/LinkTagModuleImport/explainer.md