CSS Compactor – Reduces CSS File Size

This is a script I wrote back in 2006 that reduces the file size of CSS files by removing unnecessary whitespace and comments. It’s also capable of taking such a compacted CSS file and re-indenting it to make it readable. For example, it would take the following CSS:

/* sample css */
* {
    margin: 0px;
    padding: 0px;
}

/* define style for the logo */
#header .logo {
    float: left;
    /* another comment */
}

and turn it into:

*{ margin:0px; padding:0px;}#header .logo{ float:left;}

which is equivalent but much shorter CSS code. It can also re-indent it back to:

*{
     margin: 0px;
     padding: 0px;
}
#header .logo{
     float: left;
}

Continue reading CSS Compactor – Reduces CSS File Size