Monday, November 24, 2008

Packing it in

Having finally tackled the relatively complex art of compressing JavaScript and CSS in ASP.NET, I found most of the work had already been done in the form of Packer for .NET. As I found it, Packer featured methods to compress via Dean Edward's Packer and and Doug Crockford's JSMin.

Since I wanted to combine and minify my CSS, a hunt around revealed an efficient method written by Isaac Schlueter which was incorporated into the YUI Compressor. Working from two C# ports of Isaac's code, I added CSSMinify to the pot and the result is now available.

Want more? Send a request or, even better, fetch the source and contribute your own magic.


dimebrain said...

Don't forget, as the Javascript obfuscation and variable renaming capabilities from YUI Compressor are there as well, which can produce a smaller minified result than Packer.

rez said...

The joy of Packer for .NET is in it's flexibility: it has Packer, JSMin and CSSMinify all rolled into one plus you can run it via a windows UI, command line or MSBuild. If I get the time, I might port CSSTidy to add another option to the project.

Personally I'm a little wary of too much obfuscation. Although I've been using Packer for quite some time, I've recently switched to JSMin which, combined with GZip, produces a smaller, faster loading result.