Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize media query rulesets #378

Open
jfbrennan opened this issue Dec 31, 2022 · 2 comments
Open

Optimize media query rulesets #378

jfbrennan opened this issue Dec 31, 2022 · 2 comments

Comments

@jfbrennan
Copy link

It seems like there's an optimization to be had by grouping rules from the same media queries. For example, I'm working on dark mode for a project and the minified stylesheet has six instances of @media screen and (prefers-color-scheme:dark){}. Five of those could have been removed from the output (that's 235 characters, and I'm still creating more). I can see other media queries where this should be the case as well.

Perhaps there's an edge case(s) that prevent this from being doable, but if I manually merge my six instances into one everything still works.

@devongovett
Copy link
Member

We already merge adjacent media queries, but non-adjacent rules cannot be merged safely without changing the order of the rules and thus potentially changing the behavior.

@jfbrennan
Copy link
Author

True. If the order mattered that wouldn't work. I haven't written cascading rules for maybe 6-7 years. Make it opt-in?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants