views:

115

answers:

3

jquery-1.4.2.min.js is 71.8KB Same file compressed through this tool, with gzip enabled, becomes 32.9 KB

Which is better? If latter, why doesn't jQuery provide a packed file too instead of just uncompressed and min versions?

My Question: One is minified and gzip enabled, other is minified and packed and gzip enabled. Which should I use? If the one thats 32KB, I wonder why doesn't jquery provide a minified+packed version instead, any particular reason why?

Thanks

+7  A: 

It's not an either question, use both, serve the minified file, over a gzip stream to the browser for the best/quickest delivery possibly.

Most web servers and almost every current browser support gzip. You're serving the minified file, with internal variables shortened etc...but then deliverying a zipped version of that to the client. By doing this you're delivering the minimum amount of javascript for the client to execute and delivering the smallest payload...so a quicker download for your user.

Also, remember to set cache headers so the client's not re-fetching the file...and there are other performance tips to go along with this you should read :)

Nick Craver
use both?? But they're both the same file, one is 78KB and the other 32KB, both seem to support gzip compression.
Nimbuz
@Nimbuz - You serve the `.min` file, which is compressed via the google closure compiler by the jQuery team as part of the release...your web server will gzip it for transmission to the client.
Nick Craver
Right, but the other file is even smaller than the minified file, and the server should gzip it too, why should I use the 78KB minified only vs packed file? Thats my question.
Nimbuz
@Nimbuz - gzip is relative, if you gzip a jpg you don't gain much, if you gzip a text file with repeated words, you will...same with any compression. The packed file will not benefit from gzipping *nearly* as much as the minified version.
Nick Craver
Applying the gzip compression *twice* does no good all, @Nimbuz. If it did, then you could apply it 12 times and end up with a jQuery library only 14 bytes long!
Pointy
+1 - Thanks for the useful links.
patrick dw
A: 

Gzip encoding is handled on the fly by web servers. It isn't a feature of the file uploaded to the server, so it wouldn't make sense to provide the file in that format for download.

Gzip encoding and minification are not mutually exclusive.

David Dorward
A: 

Perhaps you mean the version packed with Dean Edward's packer? It indeed yields to smaller download but requires some processing on the client-side in order to decompress it.

korchev
Yeah I think the intended question was about min + gzip vs. pack + gzip.
Rob Flaherty