CSS Compressor API

It only took a few months but I finally got it released. It's been sitting there in a little folder on my desktop for god know how long, when all it needed was a free day in my schedule to get it online! If you're a developer give it a try. You can view the full documentation at http://www.marcqualie.com/projects/css-compressor/. I will update it as often as I can, all feedback is appreciated.

The reason I'm proud of this script so much is due to the fact is has a higher compression ratio than Yahoo's YUI Compressor. Compare them if you don't believe me, and I'm still working on reducing it even further! I started working on this project when I realised every byte of data loaded into the browser counts. So rather than write neater code, I just compile it using this script so the code is perfect for browser rendering and the users of my sites. Trust me, it works.

Here is a quick example for those of you who are PHP Developers. I used this as my demo cause PHP is my primary language, so it was easy to write and instant script. If anyone wants to submit a Java or Python version feel free and I will add it to the examples. Feel free to modify the code as you need.

$key = “your_key_here”;
$css = “/* Put your css data in this string */ body { background: #FFFFFF; }”;
$url = “http://www.marcqualie.com/api/css?key=$key&level=3&format=raw”;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array(“data” => $css));
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // You may want to change this
$output = curl_exec($ch); curl_close($ch);

I realised this post is a lot shorted than usual but it's 1:30am and I'm extremely tired! Maybe i will update sometime? Anyways just give it a try and let me know what you think.

Update – 14th May The CSS Compressor API is now part of a much bigger API suite I've been developing, and will be releasing soon. The new example wrapper has been posted above, and documentation can be found at http://www.marcqualie.com/projects/css-compressor/docs.php