A basic CSS example. Every browser I have come across will render the item with the margin & padding and a red border
.test{
margin: 4px;
border: 1px solid black;
padding: 4px;
}
.test{
border: 1px solid red;
}
Naturally if I was writing this CSS by hand I would replace the black with red and only have one rule.
But If the first rule comes from a parent CSS file (or in my case a LESS file) that I can't edit because it is used elsewhere, or is from a 3rd party library that I don't want to hack then I see no alternative but to add an extra rule.
Now since I am using server side LESS -> CSS compilation with minification, it seems perfectly reasonable to me that the compressor/minifier should reduce the rules down to just
.test{
margin: 4px;
border: 1px solid red;
padding: 4px;
}
But everything I have tried, keeps both rules; some of the compressor/minifiers go as far as removing newlines
.test{margin:4px;border:1px solid black;padding:4px}.test{border:1px solid red}
It strips out a single newline character but left an entirely unnecessary rule declaration in. This seems bizarre to me.
Is there any system than can do this? (preferably an add on for node.js) If not, do we know why not? Seems like quite a big file size saving with no downside to me.
disclaimer I have tried searching for combining selectors, merging selectors and few variations, apologies if I have missed the common term for this procedure, seems likely since the gains just seem so obvious I have to be missing something!