Wednesday, December 1, 2010

Which javascript framework should I use?

The answer, of course, is: It depends.
It depends on many many things. From the complexity of your application to the deployment platform. Will it be an iPhone or iPad only webapp? will it have to support IE6? Which other constraints do you have?
If your app is simple enough, the best framework will probably be... none. Using standard javascript, standard DOM methods, etc, will be probably faster and smaller. Even if you must take into account all possible weirdness (different event model in IE and the rest of the world for example). If you are constrained to a sane subset (no IE < IE9, only safari because it's for iPad, etc) then it becomes even easier to program without any framework or library.
For a medium size app which needs to run on a variety of different browsers, a framework which supports all needed browsers will help a lot, as we won't have to reinvent the wheel for solving many browser inconsistencies. In this case the developer should be consistent on using always the framework methods when existing, and not mixing them with native javascript or DOM methods, as that could led us to difficult to find, subtle bugs.
For a big thing, the use of a framework can always help, as many needed things will be already implemented and tested, and it will provide a lot of higher level functionality missing on the javascript core language.

About which one to use... I would say it depends on what you have to do as well as your personal taste. All frameworks have their own pros and cons, and some of them are better adapted to some kind of work than others.
Personally, I really like the Google Closure Library as it's the one which more closely resembles my style of work, and what I would like a good javascript framework to provide. For different styles of working, different frameworks can be better, of course.
If you want to try the closure library (which works better in its own environment, specially regarding the Closure Compiler), I really recomend reading closure the definitive guide from Michael Bolin. It really gives a ton of good information about the Closure Tools.

No comments:

Post a Comment