Tim Harper just released an excellent RubyOnRails plugin called bundle-fu for bundling Javascript and CSS into one file. This is a really simple and powerful speedup gain you can add to your site to reduce the number of round trips to your server. The impact can be dramatic.

It does not do compression and Tim says:

Bundle-fu currently does not compress CSS or Javascript, as the speed gained by doing so is often marginal, at best.

However, I disagree with the “marginal, at best” part of that statement. Typically a JS file can be compressed upwards of 50% by just doing some simple JS compression techniques (you can also GZip the contents for an even bigger gain). For example, JQuery 1.2.1 uncompressed is 77Kb, and packed it is 26Kb and minified (Gzipped and packed) it is 14Kb.

That being said, I think its ok if bundle-fu does not add packing support since there are many different alternatives out there.

For example the new PackR plugin, a ruby port of Packer would complement bundle-fu nicely.

UPDATE: Less than two days after writing this post Tim updated Bundle-Fu to use the PackR plugin if it is installed. Impressive. You can read about it here.

2 Responses to “Bundle-Fu for combining Javascript and CSS”

  1. Tim Harper Says:

    Tom,

    Thanks for the write-up! Just wanted to let you know, you inspired me. The latest version of Bundle-Fu will automatically integrate with PackR to compress javascript.

    I ran a benchmark with the JS compressed. Overall, it shaved off about 50ms of the load time. Not nearly as big of a speed gain as bundling your assets, but still, every bit counts, right?

    gzip compression will be left to whatever is serving the page, for now.

  2. tom Says:

    Hi Tim,

    That is great news. And a very impressive turnaround. Yeah, the biggest gains are going to be the network connections… but packing definitely help shave off a bit too and could also help keep your bandwidth down.

    Also, I think it makes sense to keep gzip out of bundle-fu since most web servers have built-in support for it.

    I will update this post to reflect your latest changes.

    Thanks for writing bundle-fu. I just searched for something to do this a few days before you released it so the timing was perfect :)

    Tom

Leave a Reply