views:

205

answers:

4

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).

Since 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?

+5  A: 

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

SLaks
Is that 19kb gzipped or uncompressed?
Hank
Is that 19kb gzipped or uncompressed but minified?
Hank
That's gzipped.
SLaks
+1  A: 

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.

James Black
A: 

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).

rockacola
+1  A: 

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

Bob
It would be a lot of work. CC can be set to remove functions that aren't called, which would amount to most everything in the library. You have to explicitly tell it what not to strip out. Deleting the unused code by hand might be about as much work.
Alex JL