开发者

JQuery: how to download ONLY necessary components?

I simply want to use the JQuery Slider functionality and nothing else.

However, to do so - it's my understnading that I must download 3 files:

  1. JQuery Core
  2. JQuery UI base
  3. JQuery Slider

This totals to about 74kb (28kb gzipped).

开发者_StackOverflowSince I'm ONLY using JQuery for the Slider functionality - how can I remove all the unused JQuery base code like the Toggle function, etc easily?


Not easily.

Minified gzipped jQuery is only 19KB; it's not worth the effort.

For added performance, load jQuery.js from Google: http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js


Here's a nice jquery builder i came across: jQuery Builder

Old question but i was looking for one too and this question is showing up in Google, So probably there are other people looking for one as well. Hope this helps everyone!


It would be very difficult, but it is doable, as jQuery libraries build up on themselves, so you would need to go into each file and pull in all the functions that are needed into the slider javascript file, and eventually you should find all the functions that are needed.

But, it is so small that I don't see how you will really gain by doing this.


The Closure Compiler, the minifier jQuery is using starting with 1.4, supposedly allows you to strip code you don't need when you are compiling your script with a javascript library. Since jQuery is a library, maybe Closure Compiler will have the functionality you need. I haven't used it in this way, but this is described in the Compiler Docs:

http://code.google.com/closure/compiler/docs/api-tutorial3.html#dangers


The answer is ordinary no. If you are using plugin(s) of a Javascript framework, then naturally you will require to load in the core components (compressed or not).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜