Does anyone know of a tool that will tell me which JQuery functions are being used for a give开发者_开发百科n page? I'd like to trim down the included files to just the bare minimum. Thanks.
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:
- jQuery: http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js
jQuery UI: http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js
Look at this question for how to include the CSS from the as well (if you're using one of the default themes, modify the version number in the URLs to match the script used)
You can also modify these a bit, depending how up-to-date you want to be, for example:
- jQuery 1.4.x latest: http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js
- jQuery 1.x latest: http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
- jQuery UI 1.8.x latest: http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js
- jQuery UI 1.x latest: http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js
For reasons on why to use a CDN, take a look at this question.
精彩评论