stoyan / cssshrink

CSS minifier
1.05k stars 81 forks source link

Why only adjacent selectors / MQ ? #25

Open raphaelgoetter opened 9 years ago

raphaelgoetter commented 9 years ago

Hello,

I wonder why only the adjacent selectors / Media Queries / keyframes are packed.

Would it be possible to add an option (a checkbox labelled "great power / great responsibility") which allows packing of non-adjacent stuff ?

macgyver commented 9 years ago

I was wondering the same thing - I noticed that this input:

.a .b {
    padding-right: 10px;
}

.a .b .c {
    position: absolute;
}

.a .b {
    padding-bottom: 10px;
}

has the following output:

.a .b {
  padding-right: 10px;
}

.a .b .c {
  position: absolute;
}

.a .b {
  padding-bottom: 10px;
}

when it's possible to see that the top and bottom selectors could be combined.

Is it done this way because there's no way to guarantee the precedence is maintained otherwise?