views:

65

answers:

3

I'm writing several small things in JavaScript, notably a mousemove event, and a AJAX call. I don't believe that two things should necessitate loading the ~25KB that is jQuery. Add in the fact that I want as few external dependencies as possible and necessitating jQuery isn't something I want to do.

Is there a primer / tutorials on rewriting calls between a JavaScript library and pure JavaScript?

  • $('element')
  • $.get()
+5  A: 

For the selector part $("element"), you might as well use Sizzle, which is the same library used in jQuery and other JS framworks, and is only 4kb (minified and gzipped).

As for the $.get() call, a simple wrapper around the native XMLHttpRequest object should suffice, depending on what features exactly do you want to provide. Check the Mozilla Developper Center docs for some pointers.

jeanreis
Agreed. AJAX requests can be written directly against XMLHttpRequest; only the constructor needs a cross-browser wrapper.
harpo
A: 

jQuery uses Sizzle for its selectors magic. I can't remember if it weighs 3 or 7 kB but it's a standalone library

Felipe Alsacreations
A: 

You can study the library code, and write your own IF you want to.

Mark Schultheiss