You basically just need to edit the code and take out everything you're not
using. There's no magic for it.

The easiest way to do this is by using a text editor that can automatically
comment and uncomment blocks of code. Komodo Edit can do this; I would
expect that TextMate and most decent programmer's editors can too. Komodo
Edit is free and runs on all major platforms:

http://www.activestate.com/Products/komodo_edit/

In Komodo, just select the lines or character range that you want to comment
out and use Ctrl+3 (think of it as Ctrl+# like a Perl/Ruby style comment) to
comment out, Ctrl+Shift+3 to uncomment. Komodo will use the correct
commenting character for whatever language you're using - and in JavaScript
it's smart enough to use // comments if it can, /**/ otherwise.

If you're commenting out a line or block of code that is already preceded by
a comment, select both the comment and the code before using Ctrl+3. This
makes it easier to keep track of what to uncomment should you need to do
that later.

You can either comment out a little at a time, testing your app as you go,
or what I like to do is go for broke and comment out as much as I think I
can get away with - then uncomment whatever turns out to be needed after
all, as I run into errors in the stripped-down code.

Watch out for issues around trailing commas as you remove object members,
and that kind of syntactical stuff. Also, of course, check for code paths
that don't get executed in your normal case of loading your app.

Keep this semi-commented version of the code as your source code and run it
through Dean Edwards Packer or a simpler compressor so the comments get
stripped out in production. Don't select base 62 encoding if you use Packer
- you don't want a runtime unpacking step!

Upgrading to future versions of jQuery will be a hassle, of course! Just one
tip on that for now: A file compare program that does intraline comparisons,
such as Araxis Merge (www.araxis.com), is an enormous help here.

-Mike

> From: Steve Finkelstein
> 
> As much as I love loading all of jQuery into every single web 
> project I'm involved in, this current one is for an iPhone 
> catered web application. And to be quite blunt, loading 
> anything over EDGE is painful. I'd like to still use a few 
> methods available, such as jQuery.Ajax().
> 
> Is there a 'proper' way of using just that functionality on a 
> site instead of loading the whole library? I've seen folks 
> load libraries in their <script> tags using something like:
> 
> jquery.js?arbitrary_stuff_here
> 
> but I'm not sure what that does. Although I'm hoping it does 
> what I need it to do.

Reply via email to