views:

190

answers:

5

Uncompressed, jQuery is 160KB in size. I did not see a way to exclude seldomly used parts of it like with jQuery UI. How can I reduce the (compressed and minified) file size of jQuery? I am quite concerned because dial-up lines and slow machines/browsers are very common among users of my site.

My main concern is parsing duration of the javascript in the browser. On oldr machines this takes hundreds of milliseconds.

+2  A: 

24kb minimized and gzipped are not worth the effort IMHO.

jAndy
+14  A: 

There is no service (such as for JQuery UI) where you can pick and choose functionality. But to help:

  1. The minified version is less than 25k, which helps. The non-minified version should never really go down to the client machine.
  2. Always reference it from the same location, and the client browser should cache it.
  3. You can reference your javascript libraries after your html content, so that initial load should seem faster to the human.
  4. reference your jquery library from a different domain than yours, like from google. There are several advantages to this:
    • It is likely to get served form a location closer to your clients
    • It increases the chance that it will be download in parallel to other resources, especially with older browsers that will only download 2 items from a domain at a time.
    • It increases the chance that they won't have to load jQuery at all for your page, because it's already cached from this commonly-used site.
Patrick Karcher
I guess there is no service because most plugins depend on all functionality being there.
usr
@usr: Good point!
Patrick Karcher
A: 

jQuery is not modular. Even with dial up I don't think 24kb is a big deal.

Laplace
It is five seconds alone.
usr
+1  A: 

The minified version is 24kb minified and gzipped. jQuery UI is bundled seperately and it is modular and has a packager which allows you to choose which parts of jQuery UI you want included.

If you reference it from the google or microsoft CDN's then it will also get cached in the browser, for not just your site, but any site that uses the CDN.

lomaxx
+5  A: 

You can also let Google host jQuery for you, which gives you better caching, etc.

Robusto