views:

2913

answers:

10

I'm looking for some applications or websites that minimize css and js files. Ideally, they could batch them all or if not, one at a time.

Thanks! Brian

+2  A: 

I use Packer by Dean Edwards for javascript.

JPrescottSanders
The client side overhead of unpacking packed JS tends to outweigh the speed gains of downloading a minified file. With gzip compression the full source can even be faster than packed: http://www.ericmmartin.com/comparison-of-javascript-compression-methods/
Colonel Sponsz
+14  A: 

YUI Compressor does both JavaScript and CSS. I'm not sure if you can send it a batch of files.

You can batch process at YUI Compressor Online (yui.2clics.net), though that version only accepts JavaScript. Another Online YUI Compressor (refresh-sf.com) accepts CSS, too, but doesn't batch.

In terms of comparing the various minifiers, see this entry from the jQuery FAQ:

How do I compress my code?

Generally the best way to do it is to use the YUI compressor.

An alternative is to use Douglas Crockford's JSMin. This doesn't compress JavaScript code as small, but generally how you write your code matters less. jQuery also provides a pre-minified version of jQuery for your convenience.

Packing javascript using Dean Edwards' Packer (specifically using the base64 encode) is not recommended, as the client-side decoding has significant overhead that outweighs the file-size benefits.

If compressing your JavaScript breaks it, try running the code through JSLint. This will detect minor errors that can cause packed JavaScript to fail where the unpacked version works fine.

Since that was writter Microsoft release their Ajax Minifier and Google their Closure Compiler. jQuery has switched from YUI Compressor to the Closure Compiler for the minified version that they distribute.

bdukes
can you send me a link to that?
Brian
I've edited my answer to include links
bdukes
Thanks- does the online one allow for css or just js?
Brian
+6  A: 

YUI Compressor is pretty cool. You can run it as part of a build process from the command line

David Caunt
+3  A: 

I like this one from Yahoo: http://developer.yahoo.com/yui/compressor/

Tomh
+4  A: 

Take a look at The JavaScript CompressorRater. It does live comparisons of various minifiers (with and without gzip compression) for any JavaScript you supply it.

It also (mostly) works with CSS, though not all minifiers support it and not even all of those that do (e.g. YUI) show up correctly in the comparison table.

Ben Blank
that's really neat!
Brian
For the record, YUI supports CSS, just not through whatever method CompressorRater is using.
bdukes
Good to know, I'll update my answer.
Ben Blank
A: 

Basically what you are looking is to speed up your site by reducing the size of the response.

The other thing apart from minified js and css files is you can do a http compress. Please go through this and this.

Biswanath
A: 

If you don't mind using Perl as part of your build process, JavaScript:: and CSS::Minifier work pretty well.

Kev
A: 

you can try the free tools from Boryi

+1  A: 

There's also a .NET port of YUI Compressor which allows you to:-

  • intergrate the minification/file combining into Visual Studio post-build events
  • intergrate into a TFS Build (including CI)
  • if you wish to just use the dll's in your own code (eg. on the fly minification).
Pure.Krome
+1  A: 

Microsoft released their Microsoft Ajax Minifier on codeplex today. Includes an MS build task and everthing inside VS 2005/2008

MikeJ