1

Does anyone know of a tool that will tell me which JQuery functions are being used for a given page? I'd like to trim down the included files to just the bare minimum. Thanks.

Cyrcle
  • 1,363
  • 3
  • 13
  • 25
  • Are you talking about jQuery core, or plugins? Also, getting rid of files vs having them in a single download for the client isn't necessarily faster, there is a cost to multiple round-trips in the first place. – Nick Craver May 26 '10 at 16:14
  • I don't get it. What relevance does the amount of included files have to do with the jQuery functions that are used? Are you talking about minimising the amount of jQuery source code so it's more light on bandwidth, or to modify some plugins you use, or what? – Sune Rasmussen May 26 '10 at 16:21
  • I'd like to modify JQuery files so they only contain the functions that are needed. Core and UI. – Cyrcle May 26 '10 at 16:36
  • 1
    See http://stackoverflow.com/questions/1333465/is-it-possible-to-extract-a-subset-of-jquery – Alex Jasmin May 26 '10 at 17:17

1 Answers1

4

I don't think you'll want to go down this road, as it'll provide you very little if any benefit (and you may stab yourself in the eye trying to do it). Let me cover the 2 packages you mentioned in comments here separately.

jQuery Core is pretty small already, if you're using the minified version and serving it via gzip (and you should be doing this) then jquery is only 24kb (as of the current 1.4.2 release).

jQuery UI however is a bit heftier, you can strip down to the effects and widgets you need by using their download manager here, just select the components you need, leave the rest off, and get a minified/stripped down version that you want.


Part 2: Alternatives

Another alternative to give your users a better experience would be to include your scripts from a CDN, for example here are the links for Google's CDN:

You can also modify these a bit, depending how up-to-date you want to be, for example:

For reasons on why to use a CDN, take a look at this question.

Community
  • 1
  • 1
Nick Craver
  • 623,446
  • 136
  • 1,297
  • 1,155
  • Thanks Nick! I've sped up the site considerably by following your recommendations. I'm getting 2 files from Google's CDN, combined a bunch of CSS into one file, and enabled compression and caching on the server. Also tracked down a few missing files. Main page was formerly 31 requests and 440K, I now have it down to 17 requests and 175k. – Cyrcle May 28 '10 at 18:26
  • @Cyrcle - Good work :) Also remember that client caching helps a lot, so all those static resources aren't normally fetched either...taking it down to 1 request + ajax stuff, check out [google's page speed addon for firebug](http://code.google.com/speed/page-speed/) if you haven't, very handy :) – Nick Craver May 28 '10 at 18:31