Skip to main content
   
Andrew Roberts @ School of Computing

CSS Compressor

Overview

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.

Download

CSS Compressor is free and open source. It is released under the BSD licence.

Please select the version you wish to use:

1.0 CssCompressor-1.0.zip README CssCompressor-1.0_src.zip [source code]

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://java.sun.com and installed.


Nedstat Basic - Free web site statistics

Personal homepage website counter
< Back to software