开发者

Reducing the need for JavaScript libraries

开发者 https://www.devze.com 2023-01-04 04:18 出处:网络
I\'m writing several开发者_StackOverflow社区 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 jQuer

I'm writing several开发者_StackOverflow社区 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()


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.


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


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

0

精彩评论

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