-
Notifications
You must be signed in to change notification settings - Fork 323
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
CSS selectors merging #29
Comments
@GoalSmashers: Thanks, for opening a new issue for this; I should have done it myself already. The selectors merging can be improved even further when it's possible to use the shorthand notation like in this case: border-color: blue;
border-style: inset;
border-width: 1px; can be border: 1px inset blue; EDIT: Refs #134. |
That could be even more tricky than selectors merging! On Nov 18, 2012, at 10:07 AM, XhmikosR wrote:
|
https://github.com/css/csso |
Thanks @thezoggy. They go CSS parsing way whereas clean-css does all via RegExp replacements. And that's a totally different story. |
pretty impressive all the things it can do if you look at their test examples.. wonder if that approach makes sense or if there is a lexical top down approach (cant recall the proper term) that would be much more flexible and extensible. at least the color safe optimizations is worth referencing :). |
It is much more powerful method but at the price of being much slower (by factor of 10), as it requires much more computational effort to build a parsed tree. If we get to the point of building selectors merging I am sure it would be a quite different approach. Thanks for pointing out more safe color optimizations! |
In my opinion, this should be a higher priority. Many times it's much easier to specify a specific property instead of extending the current one. So the example from my first comment is very common. And this approach would really offer much greater compression. I hope you can reconsider this. :) |
Not before 1.0 as there are more important things than this. I wonder if it'd provide more than ~1% improvement in size though. |
Well, you shouldn't have in mind well organized css files... |
I would also suggest merging selectors with the same properties + values. Such as:
should become
I know from testing myself, after already using clean-css on some of my projects and then using CSStidy just to merge selectors in this fashion, i can get 40-50% size improvements. I'd say it's well worth the time to try implementing this. |
Thanks @CatmanIX! Once we get into attributes merging we'll definitely take a look into selectors merging too. |
Keep in mind that when a selector becomes too long, IE8 will ignore it (issue i'm running I'm having right now with compass-generated sprites) in which case doing the opposite (splitting long aggregated selectors) would actually help. Maybe a safe mode or something like that. |
Thanks for pointing that out. At first it will for sure be an optional feature. |
Raised by @XhmikosR
Another thing I was wondering, would it be very hard for clean-css to merge the selectors when they are the same? For example:
can become:
The text was updated successfully, but these errors were encountered: