min or gzip, which is better?
Asked Answered
N

3

6

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

Noonday answered 22/5, 2010 at 12:29 Comment(4)
Possible duplicate of: https://mcmap.net/q/165980/-gzip-versus-minifyHoyos
The current jQuery minified version, when served via gzip is only 24KB, so I don't understand your question, especially the edited version...your tool's making a bigger file than jQuery provides currently...Scuttlebutt
Right, but thats 24KB when served via gzip, but on my file browser it shows 78kb. The other file should be MUCH LESS in size when served via gzip because its already 32KB as my file browser shows, no?Noonday
Zip a file, zip it again, it gets larger the second time usually...not in this case, but the gzip gains on a compressed file are minimal if any at all...that 32KB won't get 60% smaller like the minified version will, take a look at Firebug to see this.Scuttlebutt
S
10

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 :)

Scuttlebutt answered 22/5, 2010 at 12:31 Comment(5)
use both?? But they're both the same file, one is 78KB and the other 32KB, both seem to support gzip compression.Noonday
@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.Scuttlebutt
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.Noonday
@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.Scuttlebutt
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!Dillondillow
I
0

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.

Islamite answered 22/5, 2010 at 12:32 Comment(0)
S
0

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.

Shively answered 22/5, 2010 at 13:22 Comment(1)
Yeah I think the intended question was about min + gzip vs. pack + gzip.Fraze

© 2022 - 2024 — McMap. All rights reserved.