[Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2473
  • Last Modified:

Using JQuery in Production Environment on Windows. Best to Gzip, Pack, Minify or leave uncompressed?

I am hosting a website on a Windows server, and I would like to use the JQuery library for some general functionality and effects.  However, the uncompressed version of the file is approx 77kb, which seems a bit much, or is that acceptable?

There are a number of versions available from the site http://jquery.com/

Minified - http://code.google.com/p/jqueryjs/downloads/detail?name=jquery-1.2.1.min.js  45.3 KB

Packed - http://code.google.com/p/jqueryjs/downloads/detail?name=jquery-1.2.1.pack.js 26.5KB

Uncompressed - http://code.google.com/p/jqueryjs/downloads/detail?name=jquery-1.2.1.js 78.6 KB

However, from the homepage itself it mentions a version being minified and gzipped as being 14KB, but there's no download link there, only to the minified version which has a 45Kb filesize.

I don't have any experience or knowledge about the differences between gzip, packed, minified etc.  What is the best method for including the JQuery library into the site?  I was under the impression that gzip was for Unix servers only, is that correct?  I have a separate Unix box which I could host the file on, but how would I reference it in the header, and would there be any problems with ssl and differing domain names.  i.e. assuming the main site is called www.windows.com and the file is hosted at https://unix.windows.com/jquery.js  ?

My initial thought is to go with the packed version at 26kb, but someone advised against it on one of the blogs related to the jquery site.  Here is what they said:

"using Packer™s redundancy reduction algorithm adds a delay at the time the script gets executed (because the script needs to be unpacked and then evaled) On my laptop, this delay is about 200 msec. The conclusion is clear: for optimal performance, gzip your JavaScript code, and stay away from advanced JavaScript compression schemes that look attractive on paper, but end up degrading the performance of your site."

And another comment:

"GZip is absolutely the correct way to compress javascript.

No eval-based compression scheme should be used because it simply takes too long to decompress the javascript file in the browser.

Don™t believe me? Consider the savings. If you save 40 kB by compression from 60 kB to 20 kB, it only takes 40 ms longer to download the full file the first time using a 8M ADSL connection.

Afterwards, you pay for the compression every time when the page is being reloaded. If it only takes 10 ms to decompress (and my measurements indicate that for my hardware it™s more like 20 ms), then after 8 page refreshes the advantage is gone.

So say yes to minimification schemes that make it possible to cache and reuse the javascript file without a decompression step.

Size isn™t everything."


Based on such information, what would be your advise, go ahead with the packed version at 26kb and disregard the execution time each time a page loads, or simply use the uncompressed version at over 77kb?  The site I am working on is targeted at the UK audience, and from what I understand, most people are on atleast 2mb broadband here.
  • 4
  • 4
1 Solution
ZvonkoSystems architectCommented:
Your last statement say it all: Do not care :)
Seriously, the script are loaded in browser only ONCE (normally), that means your refresh summery does not count.

What kind of user do you expect?  Are they on an intranet?  If so, one would expect faster retrieval of the information from the web server.  Can you do some testing of "expected" user environments?  This would give you a better understanding, and appreciation for the actual delay being experienced.  Is it noticeable, or not?
thyrosAuthor Commented:

The js library is being included on a pubic website, so users from the general internet would be accessing it; thus it would cover all scopes of environment's and connections, but overall from the limited research I have done, most users in the UK are connecting to the net via broadband, and on average that is about 2mbps, and one study says 4mbps.  Being conservative and assuming 2mbps is more widespread, it should not add too much extra weight in downloading the full uncompressed file.  I would have gone with the packer, but the comments from that jquery blog put me off, as it said there is a mini delay each time the script is 'unpacked' in the browser.

The question then, is that does the browser unpack the script on each page refresh? or is it the case that once unpacked, its done and doesn't need to be repeated again?
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

ZvonkoSystems architectCommented:
The normal standard way is that browser is set to cache the images and scripts of a page. Once cached the files are not fetched. For unzip I did never think about it but caching makes sense for me only to cache the unzipped file version.
The user can of course set his browser NOT to cache files and fetch every file again and again at every refresh.

thyrosAuthor Commented:
I would like to have this topic resolved, but I would like a bit more specific answer.  To rephrase the question,  the jquery library is coming in several formats.  Which is the best to use in windows production environment, the gzip, minified, or pack version? or just use uncompressed?

If someone can answer this:  if a packed/compressed script is used, does the browser have to unpack/uncompress the script each page load and hit, or is it the case that once downloaded and unpacked, it will not need to unpack it each page visit?  if you can provide some proof or links to verify this information, I would accept that as satisfactory answer.
thyrosAuthor Commented:
Sorry for the delay in getting back to this topic.  Zvonko should get the points for his latest post.  I will select it as the answer now.

thyrosAuthor Commented:
Thanks again.
ZvonkoSystems architectCommented:
Thanks for coming back (and for pointz :)

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now