Choosing a JavaScript library
Intro
We need a library to provide common, reusable functionality and save us from writing lots of repetitive code. Libraries also provide a layer of abstraction, thus hiding browser differences.
We do not want to write one ourselves because it saves time to use an existing one, plus these libraries are more likely to contain fewer bugs because of the significant user base.
Because of the multitude of Javascript libraries, we started our search by selecting only the most-used, most-popular and up-to-date Ajax-enabled libraries.
The contestants
|
|
Latest (non-beta) release |
Size |
the good |
the bad |
Licence |
Browser compatibility |
|---|---|---|---|---|---|---|
| Dojo |
1.0.2 (12/15/07) |
50kb+ |
|
|
modified BSD or Academic Free 2.1 |
Safari 3.0.x |
| Prototype |
1.6.0.2 (01/25/08) |
~120kb |
|
MIT |
IE 6.0+ |
|
|
1.2.2 (01/14/08) |
~26kb |
|
|
MIT or GPL |
FF1.5+ |
|
| Ext JS |
2.0.1 (01/23/08) |
500kb |
|
LGPL 3.0 |
IE 6+ |
|
| Yahoo UI Library
|
2.4.1 (12/19/07) |
29kb+ |
|
|
BSD |
IE 6+ |
| MooTools |
1.1 (05/07/07) |
9kb+ |
|
|
MIT |
IE 6+ |
| qooxdoo |
0.7.3 (01/14/08) |
|
|
LGPL or EPL |
IE 5.5+ |
|
|
1.4.61 (11/03/07) |
|
Apache 2.0 |
IE |
The pros and cons are (possibly biased) opinions collected from blogs and fora, or features promoted on the homepages.
Disqualified:
The requirements
- base for client-side restletport
- cross-browser issues:
- syntax
- DOM model
- event model
- dynamic loading of js-files
- event binding
- unit testing
- (widgets, effects)
- integration of external widgets (Simile)
- size, stability, maturity
- compression
- i18n, L10n
Popularity (by number of searches)

The other frameworks (qooxdoo, Rico, Ext js) didn't have enough search volume to show up on the graph. The seeming extreme popularity of Prototype is caused by the added searches for the prototype object of JavaScript.
Language
|
Custom event-binding |
OO |
namespaced API |
Namespacing |
Chaining |
Modular |
|
|---|---|---|---|---|---|---|
|
Prototype |
|
|||||
|
Dojo |
|
|||||
|
jQuery |
|
|
||||
|
MooTools |
|
|
||||
|
ExtJS |
|
|
||||
|
qooxdoo |
|
|||||
|
YUI |
|
There are arguments why a js framework should not try to be an OO programming language (see *,* and *).
XmlHttpRequest
All libraries contain specialized methods for Ajax calls, with support for GET and POST requests, parameters and callback functions. IFrame I/O is mostly used for file upload.
|
XHR API |
custom HTTP request headers |
Callback |
Error handling |
Cross-site scripting |
IFrame IO |
Synchronous |
|---|---|---|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
| jQuery |
|
|
|
|
|
|
| MooTools |
|
|
|
|
|
|
|
|
|
|
|
|||
|
|
|
|
|
|
||
| YUI |
|
|
|
|
CSS Framework integration
GWT wrappers
GWT + ExtJS: gwt-ext,
MyGWT
GWT + Dojo: Tatami
GWT + Script.aculo.us:
Script.aculo.us
integration
Java + qooxdoo: QWT
JavaScript Native Interface (JSNI)
Test 1: GWT Integration
- jQuery: Google Maps the jQuery Way
- YUI: Google Maps + Yahoo UI Lib (YUI) = Mashup fun
- qooxdoo: Google Maps widget
- ExtJS: Adding a Google Map to a Tab or Window
- MooTools: GMapsOverlay, google-maps-lightbox
- Prototype: gplotter
Test 2: Simile
Simile Timeline and Timeplot are based on jQuery 1.2.1, which could cause conflicts.
- Dojo: Dojo and TimeLine
- jQuery: How to make Timeline not conflict with jQuery
- GWT: gwtsimiletimeline
- Prototype: Timeline
Test 3: i18n support
- Dojo: has a specific i18n module (*).
- jQuery: no built-in i18n support. Localization is available for the datepicker-widget
- Prototype: no built-in i18n support.
- ExtJS: localization support (*, *).
- YUI: no built-in i18n support, there is however an internationalization plugin (*).
- MooTools: no built-in i18n support.
- qooxdoo: i18n and L10n are fully supported (*).
- GWT: internationalization support (*).
Test 4: Unit test
- qooxdoo: testrunner
- Prototype: there's a test framework that can be extended for custom unit tests (*).
- jQuery: internal test framework
- Dojo: has a unit testing harness, D.O.H.
- MooTools: no unit testing
- Ext JS: no unit testing (*, *)
- YUI: YUI Test
- GWT: JUnit integration
Standalone js unit test tools:
- Crosscheck
- Testcase (Prototype-based)
- Selenium
- JsUnit
Test 5: Building custom widget
jQuery:
Writing
your own plugins
Dojo: Creating new Dojo Widget,
Dojo
Custom Widget Tutorial,
Create
a Custom Javascript/AJAX Widget with Dojo
ExtJS: Writing
Ext 2 Plugins
Dojo, MooTools, jQuery, prototype: Creating an AJAX Rating Widget
The first 3 loosers
- MooTools:
- extends many of js built-in objects
- lack of namespace
- Prototype:
- extends js built-in objects
- no namespacing
- qooxdoo
- not mature enough (still beta)
The final 4
- jQuery
- blooming community
- beautiful and concise language
- Dojo
- most powerful
- Ext JS
- possibility to combine with JUI or jQuery
- YUI
- modular
- docmentation
- CSS framework included
Links
- JavaScript Frameworks Compared
- Top 5 javascript frameworks
- JavaScript Libraries By Comparison
- Javascript Toolkit Comparison
- Why I’m moving from jQuery to ExtJs
- 2007 Ajax Tools Usage Survey Results
- A Mootools Tutorial
- Choosing a JavaScript library
- Prototype and jQuery: A code comparison
- Simplify Ajax development with jQuery
- Easy Ajax with jQuery
- Survey of js frameworks


But for this: "We need a library to provide common, reusable functionality and save us from writing lots of repetitive code..." GWT is really not a contender.
It would be a good fit if your goals were to avoid maintaining any code in dynamically typed languages, or to be able to audit antipatterns with FindBugs, etc, or to leverage existing libraries written in Java that do interesting computations -- and you intend to do the whole thing, or at least large functional chunks, in GWT.