CSS Compressor
Download
- binary: CssCompressor-1.0.zip
- source: CssCompressor @ GitHub
Description
CSS Compressor is a simple Java library and utility for reducing the size of Cascading Style Sheets (CSS).
This code is forked from Yahoo's YUI Compressor, an excellent open source library for shrinking Javascript and CSS. I've made a number of enhancements to the CSS compression algorithms. Hopefully one day in the future my changes will be merged in to the YUI source. In the meantime, I wanted to share my code, hence this distribution of this stand-alone CSS component.
CSS Compressor is free and open source. It is released under the BSD licence.
Features
CSS Compressor specific:
* Merges duplicate templates. E.g. .myclassA { font-style: bold; } .myclassB { font-style: bold; } becomes: .myclassA, .myclassB { font-style: bold; } * Enhanced dimension compression. E.g., .myclass { border: 4px 4px 4px 4px; } becomes: .myclass { border: 4px; } * Additional color representation compression. * Strip last semi-colon from blocks. E.g., .myclass { font-style: bold; color: red; } becomes: .myclass { font-style: bold; color: red }
Inherited features:
* Removes unneccessary whitespace. E.g., .myclass { font-style: bold; } becomes: .myclass{font-style:bold;} * Strip units when value is 0; e.g., .myclass { margin-left: 0px; } becomes: .myclass { margin-left: 0; } * Color compression; e.g., rgb(51,102,153) -> #336699 #AABBCC -> #ABC * Remove comments * Strip empty rules.
NOTE: Before you can utilise CSS Compressor on your system, you must ensure that the Java Runtime Envinronment (version 1.5/5.0 or greater) is also installed on your computer. This can be easily downloaded from http://www.java.com and installed.