About

CSS Optimizer is a command line application that optimizes CSS code. It reduces the filesize significantly, 20-60% depending on your coding style, by stripping unneeded characters such as whitespace, tabs, newlines, and semi-colons. CSS Optimizer only eliminates characters that are not vital to proper display of the CSS file. CSS Optimizer also converts long-hand CSS declarations to short hand equivalents to eliminate even more unneeded characters. CSS Optimizer is meant to be used for production web-sites, it is not meant to be used while your web-site is in production since CSS Optimizer makes CSS code extremely hard to read. CSS Optimizer has been tested to work under many browsers such as Firefox, Mozilla, Safari, and IE; currently I have not found a browser that it does not work successfully on.

Credits

This software was written by me, Michael Bianco. It was my first program written in C, and I've gotten much better at programming in C by creating this program. Writing software, and documentation does, despite popular belief, take time and energy. If you would like to encourage further development of CSS Optimizer please consider sending a few dollars to my pay-pal account iloveitaly@comcast.net.

Usage

CSS Optimizer most basic use is to simply process a CSS file and output compressed CSS code. This can be accomplished by a simple command such as:

		cssoptimizer ./in.css
		

The above command takes the file in.css, compressed the CSS and outputs the compressed CSS code into a file names in_stripped.css. You can also specify a output file-name, so if you want the compressed css code to be placed in a file named 'compressed.css' you could use the following command:

		cssoptimizer ./in.css ./compressed.css
		

CSS Optimizer also has a number of options you can give it to change its execution behavior. For instance if you wanted to save the compressed CSS code in the original file given for processing you could the -s option:

		cssoptimizer ./in.css -s
		

There are a number of command line options you can pass to CSS Optimizer:

-l Turns off long-hand to short hand conversion
-s Compressed CSS code will be inserted into the original CSS file (reffered to as inputfile throughout the rest of this document). If you use this option do not specify an ouput file-name. CSS Optimizer will create a file using the same name as your inputfile file with a '_unstripped' suffix that will contain the unprocessed CSS code. If you want dont want CSS Optimizer to create a backup file, use the -n option.
-h If the inputfile is single file CSS Optimizer treats that file as a html file. If a directory was specified along with the -r argument all files ending in .htm or .html will be processed as html files.
-r Enables recursive directory searching. Do not specify a outputfile, simply specify a directory as the inputfile with any other optional options (-l, -s, -q, etc) and CSS Optimizer will find all files in the specifed directory, and files in any child directories, with the extension .css (.htm and .html files will also be found if the -h option was specified) .
-n Specifies that no backup file will be created, this option only works in combination with the -s option.
-i Compress CSS code piped into stdin
-o Output compressed CSS code to stdout. This command can only be used when compressing a single css file, or when compressing code from stdin with the -o argument.
-q Suppress result information

Options can be entered in any order, and can be combined. The only restriction is that your output file (if you supply one) must be entered after your inputfile. For instance if you wanted to save the compressed CSS code in the original file without creating a backup file and recieving result information; both of the following commands would work:

		cssoptimizer ./in.css -n -s -q
		cssoptimizer ./in.css -nsq
		

Bugs, Feature Requests, Source Code, and Updates

Please E-mail Me with any bug reports, and feature requests. You can Download the full source code. All updated will be announced on my Blog and posted on the Download Page.

License

This software is OSS (Open Source Software) and is released under the GPL license. You can learn more about the GPl license here. If you want to bundle CSS Optimizer with your application let me know.