jianlinwei / cssmin

Automatically exported from code.google.com/p/cssmin
0 stars 0 forks source link

Plugin to combine/minify rulesets and ruleset declarations #34

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What version of CssMin are you using (source and/or build)?
2.0.2.2

What was the input stylesheet and/or configuration options?
Input was given in a very development friendly format.

What is the expected result?
h1 *{font:normal 26px "Trebuchet 
MS",tahoma,arial;padding:0;color:#748FA5;line-height:35px;margin:0 0 10px}

And what is the actual result and/or error message?
h1 
*{font-size:26px;padding:0;font-weight:normal;color:#748FA5;line-height:35px;fon
t-family:"Trebuchet MS", tahoma, 
arial;margin-top:0;margin-right:0;margin-bottom:10px;margin-left:0}

Please provide any additional information below.

Simply 76 bytes data is still there in just one rule. You can trim white space 
between two font names, combine font-weight, font-family and font-size 
properties. Also when margin-top, margin-right, margin-bottom, margin-left is 
used, you can safely combine to make one property (as shows in above). Same 
applies to padding.

I hope this gets considered soon because 76 bytes left from being trimmed from 
just one rule is just too much for me to ignore.

Also if these issues are considered for next releases, it would become very 
easy for us to maintain a very developer friendly and long explained CSS file 
on the server, that gets served in just few thousand bytes.

Otherwise, this is a good script and I just downloaded it for using for the 
first time.

Original issue reported on code.google.com by praise...@gmail.com on 5 Jun 2011 at 7:32

GoogleCodeExporter commented 9 years ago
Also noted that "background-image", "background-repeat","background-position" 
can be combined.

Original comment by praise...@gmail.com on 5 Jun 2011 at 7:38

GoogleCodeExporter commented 9 years ago
Also that "border-bottom-width", "border-bottom-style" and 
"border-bottom-color" can be combined to make one rule border:1px solid #000;

Original comment by praise...@gmail.com on 5 Jun 2011 at 7:41

GoogleCodeExporter commented 9 years ago
If some style is repeated accidentally, although this is the fault of the 
coder, yet the repeated property or rule can be removed safely.

The following is common problem when we use more than one CSS files and 3rd 
party CSS templates etc. Plug ins (like jquery plug ins have own CSS), 
frameworks etc. These are all the body tags collected from all CSS files:

body {
     background-color:#fff;
     color: #000;
     background-color:#fff;
     margin:0
}

body {
     text-decoration: underline;
     color: #666666;
}

body {}

body {
     text-decoration: underline;
     color: #666666;
}

If I am not wrong, it can be rewritten as:

body{background-color:#fff;margin:0;text-decoration:underline;color:#666}

(see the ; is there after margin:0 that is not in the original code)

Hope all my suggestions are useful for the script.

Original comment by praise...@gmail.com on 5 Jun 2011 at 7:50

GoogleCodeExporter commented 9 years ago
Thanks for your feedback.

I'm aware of the additional minification possibilities. The current status is 
that CSSMin tries to avoid to change a ruleset, ruleset declaration, etc. to 
preserve their lexical meaning. For example there are some browser hacks 
depending on double definition of rulesets or ruleset declarations like 
Clearfix or the IE min-height hack.

I'm considering to create a optional plugin for CSSMin version 3 to combine 
rulesets and/or ruleset declarations.

Original comment by joe.scylla on 15 Jun 2011 at 11:25