CSS Strip

6 May, 2008

Summary

CSS Strip is a simple Windows command line application to remove comments and extra whitespace from CSS files. I use it in a batch file to process the deployment of a large web application with about a thousand lines of code across several CSS files.

Download

Strip.zip 3KB

Requires Windows and .NET Framework 3.5.

Extract the .exe file. Put it somewhere and it to the Windows path variable or put it in the folder you will run it from. I have it in a folder with a batch file I use to copy the web application then run Strip and some other tools on the copy.

Example

Command

C:\Strip input.css output.css

input.css

/* Comment */



body { background: black;
color: white;

}

/******************
Multi
line
comment
******************/

div p   { color: #eeeeee; !important }

output.css

body { background: black;color: white;}
div p { color: #eeeeee; !important }

Batch file

Here is how you could use it in a batch file to optimize all the CSS files in a folder:

@echo off
FOR %%f IN (*.css) DO (
 Strip.exe %%f %%f.temp
 move %%f.temp %%f
)

Just paste it into an empty text file and give the file a .bat extension. I use similar code in a larger batch file as one step of several.

Notes

License and disclaimer

Download and use this for free. This work is licensed under a Creative Commons Attribution 3.0 Unported License which means you can use it for pretty much anything.

Creative Commons License

I offer no support, guarantees, or warrantee. Use at your own peril. All I can say is it works for me.


©2008 Jade Ohlhauser