JQuery alternative when only DOM traversal is required, $ .ajax & Deferred

Edit (2012-04-12): Since this question has been asked, now (with jQuery 1.8) before creating custom jQuery assemblies .


For most of the JavaScript projects I'm working on, I want a simple, easy user interface.

I am currently using jQuery in my projects, however, when I really take a step back and look at the code, I use it only for:

Is there another library (I don’t want to handle all the different cross-browser and ES3 / ES5 differences) that can provide me with these functions without all the additional functions that I personally don’t need?

Dojo arises, but I have little experience with this until now, and ideally I would like to hear from those who used several libraries for this.

+7
source share
2 answers

In a minimized form, Dojo is 136kb, jQuery is 96kb. Moving to Dojo is not going in the right direction.

You should consider the following questions:

  • The suitability of the library for your purpose
  • Library size
  • The likelihood that it will already be prepared
  • Your acquaintance with the functionality of the library
  • Availability on the popular, publicly available CDN
  • Good online support and excellent documentation.
  • Good reputation for reliability, cross-browser support and regular updates.

Go through each of them, and if you do not find another library that appreciates them well, jQuery may be your best bet. It is surprisingly compact for what it offers you, and in fact it does not have many things that are not on your list of things that you want. jQuery did a pretty good job of keeping the core library focused on its central mission and letting the user interface components go into jQueryUI and much more into their own plugin libraries.

If you're obsessed with optimizing the code you include to be just what you need, then you can take a look at YUI. It was designed to be modular so that you can specify only the modules you need, and then you can pre-create a piece of code that contains only those modules (or you can dynamically load only the necessary modules). I believe that YUI is somewhat overestimated in this regard, and it is cumbersome to use for fast projects because you need to spend time to figure out which modules you need and generate them every time. After you get a bunch of loaded modules, it is not so compact that you will find that jQuery is surprisingly compact for what it includes.

In general, you should not worry that the library includes something that you are not using. Just look at the overall size and suitability of the libraries that suit your needs. You can probably find a library that does just what you want, and more than jQuery, and is not cached so widely that there is no gain.

There are compact libraries for just ajax or just deferred, but you probably want one with ajax and deferred to run together, so you can use deferred with ajax (as jQuery did). Libraries that do extensive DOM manipulation are usually more than just because they are more intended for your main library, and most people have other needs besides DOM manipulation.

In the end, I would suggest that you don't care what your library has that you don't need. Just appreciate its overall suitability and alternatives.

+4
source

Take a look at http://microjs.com/ and use what you need.

+5
source

All Articles