PHP CSS Compressor

Written on Tuesday August 5th 2008 at 8:03 am

 



Compressing CSS is a great way to save some bandwidth, especially on more complex sites with stylesheets reaching more than 1000 lines of code. There are many websites out there that will compress your stylesheets for you, but the problem is maintaining them afterwards. Either search through a cryptic block of code, or keep backups and recompress after every change. While you might save file size, you'll probably lose development time.

With this CSS compressor, you upload and edit your stylesheet as you usually would. The compressor opens the stylesheet, compresses it, then outputs it to a compressed version.

How to use it:
First, download this package: php_css_compress_0_2_1.zip

Second, use this code to include the stylesheet in your <head> tag: <link rel="stylesheet" href="css_compress.php?stylesheet=mystylesheet.css" type="text/css" /> Change mystylesheet.css to the desired stylesheet you wish to use. The compressor is directory relative, so if your stylesheet is in a different directory you can change mystylesheet.css to styles/mystylesheet.css or however you see fit.

Cheers!

2 Comments

Guest

On Tuesday August 5th 2008 at 9:48 pm Guest said

what version of php does this work with?

Guest

On Friday August 8th 2008 at 7:14 pm Guest said

Works pretty good except the php file itself is 4kb, good for big style sheets though.

Add a comment or Login

Your Name: *

Your Email: *

Choose a Password: *

Confirm Password: *

Comments: *


Are you Human? Please enter the number you see above (for verification purposes)