Re: [csswg-drafts] [CSS Import Once] @import-once, or some syntax for importing a stylesheet only once (#6130)

@LeaVerou hello! Here is the core use case:

We want to build a feature-rich CSS library where users can import a specific component (e.g., a button or popup tooltip) without manually managing its sub-dependencies or importing the entire library.

Currently, users must manually map out the dependency graph and maintain a strict `@import` order to avoid load-order issues—mirroring the old jQuery <script> tag problem. While `@layer` can manage the cascade, it is overly complex for simple dependency management.

CSS Modules would solve this the same way ES Modules do, with a simple mental model:

- **Automatic Resolution:** Dependencies are determined and loaded automatically.
- **Predictable Ordering:** The module tree ensures deep dependencies load before the modules that rely on them.
- **Simplified Workflow:** Import order dictates the load order (regardless of cascade), just like JS.

The goal is to solve the dependency pain of manual imports without forcing users to rely on complex cascade layers, though layers would still exist for advanced scoping.

-- 
GitHub Notification of comment by trusktr
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6130#issuecomment-4346069714 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 29 April 2026 17:36:55 UTC