Solved

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

Posted on 2007-11-25
10
2,415 Views
Last Modified: 2013-11-19
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."

http://www.julienlecomte.net/blog/2007/08/13/

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.
0
Comment
Question by:thyros
  • 4
  • 4
10 Comments
 
LVL 63

Expert Comment

by:Zvonko
ID: 20347341
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.

0
 
LVL 41

Expert Comment

by:HonorGod
ID: 20347692
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?
0
 

Author Comment

by:thyros
ID: 20372760
Hi,

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?
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 20378061
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.

0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:thyros
ID: 20810904
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.
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 500 total points
ID: 20812185
0
 

Author Comment

by:thyros
ID: 20971967
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.

Thanks.
0
 

Author Closing Comment

by:thyros
ID: 31410867
Thanks again.
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 20973431
Thanks for coming back (and for pointz :)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now