[csswg-drafts] [css-conditional-5][css-nesting-1] Allow browsers with Nesting support to suppress stylesheet imports (#9082)

SebastianZ has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-conditional-5][css-nesting-1] Allow browsers with Nesting support to suppress stylesheet imports ==
In #8399 we discussed what's the path forward for browsers that do support CSS Nesting plus feature detection vs. those that do not.

The main issue is that browsers shipped Nesting without implementing feature detection beforehand. And without feature detection the usage of nested rules is restricted to non-essential rules if you want to avoid breaking the layout.

So `@import "compiled-to-nonnested.css" not supports(selector(&));` as [mentioned](https://github.com/w3c/csswg-drafts/issues/8399#issuecomment-1428345723) by @LeaVerou doesn't work.

@romainmenke [noted the same](https://github.com/w3c/csswg-drafts/issues/8399#issuecomment-1417100459) saying that the following doesn't work:

```css
@import "nested-and-small.css" supports(selector(&));
@import "not-nested-and-large.css" not supports(selector(&));
```

Browsers that do not support `supports()` fail to apply both, independently of whether they support nesting.

So in order to support those, you need to have one `@import` without condition (instead of `not supports()`. Though that means that browsers that _do_ support  `support()`, will then import both stylesheets. And that's not a good path forward performance-wise.

Therefore, there should be a way for those that interpret `support()` to suppress loading the ones without condition.

I don't have a good proposal for that at hand, unfortunately. The only way I can see is to indicate that via the stylesheet name. So e.g. if the name contains "non-nested", then ignore it.

Sebastian

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9082 using your GitHub account


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

Received on Tuesday, 18 July 2023 18:35:15 UTC