83
JavaScript Libraries Ajax Experience - October 2007 John Resig (ejohn.org)

JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

  • Upload
    hahanh

  • View
    233

  • Download
    4

Embed Size (px)

Citation preview

Page 1: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

JavaScript LibrariesAjax Experience - October 2007

John Resig (ejohn.org)

Page 2: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Question: How do you want to write JavaScript?

Page 3: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

1) Plug-and-Play

• Drop in a “calendar widget” or “tabbed navigation”

• Little, to no, JavaScript experience required.

• Just customize some options and go.

• No flexibility.

Page 4: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

2) Some Assembly Required

• Write common utilities

• Click a link, load a page via Ajax

• Build a dynamic menu

• Creating interactive forms

• Use pre-made code to distance yourself from browser bugs.

• Flexible, until you hit a browser bug.

Page 5: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

3) Down-and-Dirty

• Write all JavaScript code from scratch

• Deal, directly, with browser bugs

• Quirksmode is your lifeline

• Excessively flexible, to the point of hinderance.

Page 6: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

What we’ve just seen...

• Widgets

• Libraries

• Raw JavaScript

Page 7: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

What we’ve just seen...

• Widgets

• Libraries

• Raw JavaScript

Page 8: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Why use a library?

• Makes JavaScript bearable

• Gets the job done fast

• Simplifies cross-browser support

• Sort of like C stdlib - no one just codes all of C by hand

Page 9: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

What kind of libraries exist?Open Source Commercial

Client/ Server

AjaxCFCQcodo

AtlasBackbase for

Struts

Browser Only

PrototypejQuery

Yahoo UIDojo

BackbaseSmartClient

Page 10: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

What kind of libraries exist?Open Source Commercial

Client/ Server

AjaxCFCQcodo

AtlasBackbase for

Struts

Browser Only

PrototypejQuery

Yahoo UIDojo

BackbaseSmartClient

Page 11: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Open Source LibrariesBrowser Only Client/Server

Task Specific

Scriptaculousmoo.fx

Open Rico

AjaxCFCQcodo

General Purpose

PrototypejQuery

Yahoo UIDojo

Ruby on RailsCakePHP

Page 12: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Open Source LibrariesBrowser Only Client/Server

Task Specific

Scriptaculousmoo.fx

Open Rico

AjaxCFCQcodo

General Purpose

PrototypejQuery

Yahoo UIDojo

Ruby on RailsCakePHP

Page 13: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Why these libraries?

Page 14: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Ajaxian Survey

35%

25%

21%

20%

Prototype jQuery Yahoo UI Dojo

http://ajaxian.com/archives/ajaxian-2007-survey-results

Page 15: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Google Trends

jQuery

Prototype

DojoYahoo UI

http://google.com/trends?q=prototype+javascript%2C+jquery+javascript%2C+yui+javascript%2C+dojo+javascript&ctab=0&geo=all&date=all&sort=0

Page 16: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

The Libraries

Page 17: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Prototype

Page 18: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Prototype: Overview

• Started early 2005 by Sam Stephenson

• Incredibly popular, tied with Ruby on Rails’ popularity

• Development backed by 37 Signals

Page 19: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Prototype: Focus

• Improving the usability of the JavaScript language

• Big emphasis on adding in ‘missing’ JavaScript features

• Clean structure, clean objects and ‘classes’

Page 20: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Prototype: Details

• Code quality is fantastic, great features

• All animations (and interactions) are in Scriptaculous

• Updated frequently

• Looking at Prototype 1.6.0

Page 21: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

jQuery

Page 22: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

jQuery: Overview

• Released January 2006 by John Resig

• Rapid rise in popularity

• Many developers across the globe

Page 23: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

jQuery: Focus

• Improving the interaction between JavaScript and HTML

• Finding elements then performing actions

• Highly-effective, short, code

Page 24: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

jQuery: Details

• Core features are limited to DOM, Events, Effects, Ajax

• Other features can be added in via plugins

• Looking at jQuery 1.2.1

Page 25: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Yahoo! UI

Page 26: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

YUI: Overview

• Released Feb 2006 by Yahoo!

• Maintained and financed internally

• Attempt to standardize internal JavaScript

Page 27: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

YUI: Focus

• Exposing, and solving, common methodologies

• Looking for common idioms (Drag-and-Drop, Calendar, Auto-Complete)

• Looking at Yahoo UI 2.3.1

Page 28: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Dojo

Page 29: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Dojo: Overview

• Started early 2005 by Alex Russell + Co.

• Large development community

• Lots of corporate backing (IBM, AOL)

• Big code base, tons of features

Page 30: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Dojo: Focus

• Building complete web applications

• A package heirarchy, e.g.:dojo.addClass( ... )

• Focus has transcended into widgets (Dijit)

• Huge number of features

• Today we’re looking at Dojo 0.9

Page 31: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

What should a library have?

Page 32: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Code Base

• Core Functionality

• DOM

• Events

• Ajax

• Animations

• User Interface Widgets

Page 33: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Development

• Good Architecture

• Open Licensing

• Wide Browser Support

• Small File Size

Page 34: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Project

• Development Team (Open, Funded)

• Code in SVN / Bug Tracker

• Good Unit Test Coverage

Page 35: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Documentation

• Full API Coverage

• Plenty of Tutorials

• Some Books

• Wide variety of Demos

Page 36: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Community

• Active Mailing List / Forum

• Support and Training

• Popularity

Page 37: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Code Base

• Core Functionality

• DOM

• Events

• Ajax

• Animations

• User Interface Widgets

Page 38: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Core Functionality

• Bare minimum needed to make a dynamic “Ajax” web site:

• DOM (Traversal and Manipulation)

• Events

• Ajax

• Animations

Page 39: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

DOM

• Traversal

• Using CSS selectors to locate elements

• Modification

• Create/remove/modify elements

• Having a DOM builder is important

Page 40: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

DOM Traversal

• Prototype:$$(“table > tr”)

• jQuery:$(“div > p:nth-child(odd)”)

• Dojo:dojo.query(“table tr:nth-child(even)”)

• Yahoo UI:No querying support

Page 41: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

DOM Modification

• Prototype:Insertion.Bottom(“list”,”<li>Another item</li>”);

• jQuery:$(“#li”).append(“<li>An item</li>”);

• Dojo and Yahoo UI have weak support - no DOM building capabilities, basic property modification

Page 42: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Events• Support for simple event binding/removal

• Support for custom events is essential

• Prototype:Event.observe(“button”,”click”, function(){ alert(“Thanks for the click!”);});

• jQuery:$(“div”).click(function(){ alert(“div clicked”);});

Page 43: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Events (cont.)

• Yahoo UI:YAHOO.util.Event.addEventListener(“list”, “click”, function(){ alert(“List Clicked”);});

• Dojo:dojo.connect(dojo.byId("mylink"), "click", function(){ alert(“Link clicked”);});

Page 44: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Custom Events

• $(“#list”).bind(“drag”, function(){ $(this).addClass(“dragged”);});

• $(“#test”).trigger(“drag”);

Page 45: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Ajax• Request and load remote documents

• Prototype:new Ajax.Request(“test.html”, { method: “GET”, onComplete: function(res){ $(‘results’).innerHTML = res.responseText; }});

• jQuery:$(“#results”).load(“test.html”);

Page 46: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Ajax (cont.)• Yahoo UI

YAHOO.util.Connect.asyncRequest( 'GET', “test.html”, function(data){ YAHOO.util.Dom.id(“results”).innerHTML = data; });

• Dojodojo.io.bind({ url: "test.html", method: "get", mimetype: "text/html", load: function(type, data) { dojo.byId(“results”).innerHTML = data; }});

Page 47: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Ajax (cont.)

• jQuery is only one capable of doing DOM traversing over XML

• jQuery.get(“test.xml”, function(xml){ $(“user”, xml).each(function(){ $(“<li/>”).text( $(this).text() ) .appendTo(“#userlist”); });});

Page 48: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Animations

• Simple animations (hide/show/toggle)

• Provide elegant transitions

• No animations in Prototype Core (see Scriptaculous, instead)

• jQuery:$(“#menu”).slideDown(“slow”);

Page 49: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Animations (cont.)

• Yahoo UI:new YAHOO.util.Anim(“list”, { width: { from: 10, to: 100 } }, 1, YAHOO.util.Easing.easeOut);

• Dojo:dojo.fadeOut({ node: dojo.byId(“list”), duration: 500 });

Page 50: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Core Feature Summary

DOM Events Anim. Ajax

Prototype X X - X

jQuery X X X X

Yahoo UI / X X X

Dojo / X X X

Page 51: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

User Interface Widgets

• ejohn.org <-- slides

• Difficult to implement components, made easy

• Commonly used, save duplication

• Some common components:Drag & Drop, Tree, Grid, Modal Dialog,Tabbed Pane, Menu / Toolbar, Datepicker, Slider

Page 52: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

User Interface Packages

• Only looking at officially-supported code:

• Prototype has Scriptaculous

• jQuery has jQuery UI

• Dojo has Dijit

• Included in Yahoo UI

Page 53: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Drag & Drop

• Drag an item from one location and drop in an other

• Supported by all libraries

Page 54: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Tree

• A navigable hierarchy (like a folder/file explorer)

• In Dojo and Yahoo UI

Page 55: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Grid

• An advanced table (resizable, editable, easily navigable)

• In Dojo and Yahoo UI

Page 56: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Modal Dialog

• Display confined content (usually drag & droppable) and confirmation dialogs

• In Dojo, Yahoo UI, and jQuery

Page 57: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Tabbed Pane

• Multiple panes of content navigable by a series of tabs

• In Dojo, Yahoo UI, and jQuery

Page 58: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Menu / Toolbar

• A list of navigable items (with sub-menus)

• In Dojo and Yahoo UI

Page 59: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Datepicker

• An input for selecting a date (or a range of dates)

• In Dojo, Yahoo UI, and jQuery

Page 60: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Slider

• A draggable input for entering a general, numerical, value

• In all libraries

Page 61: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Tons More!

• Color Picker (Dojo, YUI)

• Layout (Dojo, YUI)

• Auto Complete (Dojo, Proto, YUI)

• Selectables (Proto, jQuery)

• Accordion (Dojo, jQuery)

• WYSIWYG (Dojo, YUI)

Page 62: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Themeing

• A consistent look-and-feel for widgets

• jQuery, Yahoo UI, and Dojo provide themeing capabilities

• jQuery’s and Yahoo UI’s are documented

Page 63: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Accessibility

• Taking in to consideration points from ARIA (Accessible Rich Internet Applications)

• Dojo is taking a solid lead, here

Page 64: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Development

• Good Architecture

• Open Licensing

• Wide Browser Support

• Small File Size

Page 65: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Architecture

• Bottom Up (Prototype, jQuery) vs. Top Down (Dojo, Yahoo UI)

• jQuery, Dojo, and Yahoo UI all use a single namespace

• Prototype extends native objects (high likelihood of inter-library conflict)

• jQuery is extensible with plugins

Page 66: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Licensing

• All use liberal licenses (“Keep my name on the file, don’t sue me.”)

• MIT:Prototype, jQuery

• BSD:Yahoo UI, Dojo

Page 67: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Browser Support

• Everyone supports:IE 6+, Firefox 2+, Safari 2+, Opera 9+

• Except:

• Prototype doesn’t support Opera

• Dojo is dropping support for Safari 2

Page 68: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

File Size

• Serving your JavaScript minified + Gzipped

• Optimal level of compression and speed

• Core file size (in KB):

0

8.75

17.50

26.25

35.00

Prototype jQuery Yahoo UI Dojo

Page 69: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Project

• Development Team (Open, Funded)

• Code in SVN / Bug Tracker

• Good Unit Test Coverage

Page 70: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Development Team

• Prototype, jQuery, and Dojo all have open development (anyone can contribute)

• jQuery, Yahoo UI, and Dojo all have paid, full-time, developers working on the code

• All have paid, part-time, developers

Page 71: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

SVN / Bug Tracker

• Prototype, jQuery, and Dojo all have code in a public SVN repositor

• Yahoo UI’s development is private and is limited to Yahoo employees

• All libraries have a public bug tracker

Page 72: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Unit Tests

• All libraries have some automated unit tests

• jQuery, Yahoo UI, and Dojo all have public unit tests

• jQuery and Dojo have tests that can run in Rhino

Page 73: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Documentation

• Full API Coverage

• Plenty of Tutorials

• Some Books

• Wide variety of Demos

Page 74: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

API Documentation

• Prototype, jQuery, and Yahoo UI all have full coverage

• jQuery provides runnable examples with each API item

• Dojo’s coverage is spotty - work in progress

Page 75: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Tutorials

• All libraries provide some tutorials

• jQuery and Yahoo UI have screencasts

• Prototype: 6

• jQuery: 68 (English)

• Yahoo UI: 32

• Dojo: 5

Page 76: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Books• Prototype:

• Prototype and Scriptaculous in Action (Manning)

• Prototype and Scriptaculous (Pragmatic)

• jQuery:

• Learning jQuery (Packt)

• jQuery Reference Guide (Packt)

• Yahoo UI: None

• Dojo: A short online book

Page 77: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Demos

• Yahoo UI provides a considerable number of live demos and examples for all features

• jQuery provides live examples and a few demo applications

• Dojo provides demo applications for their widgets

Page 78: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Community

• Active Mailing List / Forum

• Support and Training

• Popularity

Page 79: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Mailing List / Forum

• Prototype, jQuery, and Yahoo UI have mailing lists

• Prototype: 23 posts/day

• jQuery: 108 posts/day

• Yahoo UI: 36 posts/day

• Dojo has an active forum

Page 80: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Support and Training

• Dojo provides paid support and training (via Sitepen)

Page 81: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Popularity

• Who uses what:

• Prototype: Apple, ESPN, CNN, Fox News

• jQuery: Google, Amazon, Digg, NBC, Intel

• Yahoo: Yahoo, LinkedIn, Target, Slashdot

• Dojo: IBM, AOL, Mapquest, Bloglines

Page 82: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

More Information

• Prototype:http://prototypejs.org/

• jQuery:http://jquery.com/

• Yahoo UI:http://developer.yahoo.com/yui/

• Dojo:http://dojotoolkit.org/

Page 83: JavaScript Libraries - read.pudn.comread.pudn.com/downloads106/ebook/437831/ajaxlibs.pdf · What kind of libraries exist? Open Source Commercial Client/ Server AjaxCFC Qcodo Atlas

Ajax Experience Presentations

• Presentations on:

• Dojo (2)

• Prototype (2) & Scriptaculous (1)

• jQuery (3)

• Go to one that sounds interesting and enjoy!