I'm looking for a web service or (OS X) software that will take a style sheet like this one:
h1,h2 {margin-bottom:1em;}
h2.special {color:red;text-align:justify;}
p {margin-bottom:1em;font-weight:bold; }
and transform it into this:
h1,h2,p {margin-bottom:1em;}
h2.special {color:red}
h2.special {text-align:justify;}
p {font-weight:bold;}
I.e., I need something that will take each unique attribute / value combination in a CSS file and then group all selectors that use it.
It seems to me that this is a trivial problem, but the only bit of “coding” I’m capable of is a bit of RegEx - seems that doesn’t give me a solution here.
Thank you.
Note:
I'm aware that this approach may not lead to (size) optimization. It's not for a live site/CSS, but to analyze and "weed out" unnecessarily complex style sheets. After that step, attributes will be grouped again.
Try this: http://www.cssoptimiser.com/optimize.php
Although I'm not sure how converting h2.special {color:red;text-align:justify;}
to
h2.special {color:red}
h2.special {text-align:justify;}
would be an improvement. But that optimizer did do the other part (margin-bottom).
Basically just google "CSS optimizer"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With