Top Banner
jQuery 1.3 and jQuery UI John Resig http://ejohn.org / - http://twitter.com/jeresig/
24

jQuery 1.3 and jQuery UI

Aug 20, 2015

Download

Technology

jeresig
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: jQuery 1.3 and jQuery UI

jQuery 1.3 andjQuery UI

John Resighttp://ejohn.org/ - http://twitter.com/jeresig/

Page 2: jQuery 1.3 and jQuery UI

jQuery✦ jQuery Plugins✦ jQuery UI

✦ Themeroller✦ jQuery 1.3:

✦ Selector Engine✦ Manipulation✦ Sniffing

✦ jQuery Testing✦ jQuery Performance

Page 3: jQuery 1.3 and jQuery UI

Plugins✦ Huge plugin ecosystem✦ Managed by Plugin tracker

http://plugins.jquery.com/✦ Hundreds in the tracker - even more on

the web

Page 4: jQuery 1.3 and jQuery UI

jQuery Plugins✦ Extend the jQuery system✦ Add on extra methods:

jQuery(“div”).hideRemove();✦ Trivial to implement:

jQuery.fn.hideRemove = function(speed){ return this.hide(speed, function(){ jQuery(this).remove(); });};

Page 5: jQuery 1.3 and jQuery UI

jQuery UI✦ A complete set of themed, cross-browser,

user interface components (plugins!).✦ Drag, Drop, Sort, Select, Resize✦ Accordion, Datepicker, Dialog, Slider, Tabs✦ More info:

http://ui.jquery.com/✦ 1.6 is almost ready

Page 6: jQuery 1.3 and jQuery UI

Accessibility✦ Keyboard Accessible✦ Screenreader Accessible✦ Grant from Mozilla Foundation to

implement ARIA

Page 7: jQuery 1.3 and jQuery UI

Support✦ Full-time developer:

✦ Paul Bakaus✦ Hired by LifeRay

Page 8: jQuery 1.3 and jQuery UI

Themeroller✦ Customize the styling of any jQuery UI

component✦ Full CSS, images for all components✦ Easy to customize and use✦ http://themeroller.com/

Page 9: jQuery 1.3 and jQuery UI

Todo Listhttp://jquery.com/files/todo/

http://jquery.com/files/todo/done.php

Page 10: jQuery 1.3 and jQuery UI

jQuery 1.3✦ Selectors✦ DOM Modification✦ Browser Sniffing

Page 11: jQuery 1.3 and jQuery UI

Selectors

Page 12: jQuery 1.3 and jQuery UI

Code name “Sizzle”✦ http://github.com/jeresig/sizzle/tree/master✦ New Selector Engine for jQuery✦ 1.5 - 4x faster than other libraries✦ 4KB Compressed✦ No dependencies, can be used by other

libraries (MochiKit, Prototype, Dojo)

Page 13: jQuery 1.3 and jQuery UI

Manipulation✦ Four common methods:

append, prepend, before, after✦ $(“<li>and this too!</li>”)

Page 14: jQuery 1.3 and jQuery UI

Injecting✦ Loop through elems, cloneNode(true)

each, insert into DOM✦ 5 paragraphs✦ 100 divs✦ 2 method calls (insert, clone)✦ 1000 method

✦ *Very* slow✦ Simple plugin provides 10-15x speed-up:

http://dev.jquery.com/~john/ticket/append/

Page 15: jQuery 1.3 and jQuery UI

Document Fragments✦ Move the nodes into a Document

Fragment✦ Husk DOM container✦ Whole container can be cloned✦ and whole container can be injected✦ Saves a ton of repetition

Page 16: jQuery 1.3 and jQuery UI

Sniffing✦ All major JS libraries use browser sniffing✦ Look at the user agent and make guesses

✦ navigator.userAgent is bad! :-(✦ We can get rid of this!✦ Makes our code more resilient to change

Page 17: jQuery 1.3 and jQuery UI

Detection✦ Object Detection

✦ if ( document.getElementsByTagName )✦ Feature Simulation

✦ var div = document.createElement(“div”);div.innerHTML = “<!--test-->”;var a = div.getElementsByTagName(“*”);if ( a.length > 0 ) { // Why did we match a comment?}

Page 18: jQuery 1.3 and jQuery UI

Testing

Page 19: jQuery 1.3 and jQuery UI

JavaScript Test Suite✦ qUnit (jQuery Test Suite)

http://docs.jquery.com/QUnit✦ By Joern Zaefferer

Page 20: jQuery 1.3 and jQuery UI

qUnit Usage✦ test("a basic test example", function() {

ok( true, "this test is fine" ); var value = "hello"; equals( "hello", value, "We expect value to be hello" );});

module("Module A");test("first test within module", function() { ok( true, "all pass" );});test("second test within module", function() { ok( true, "all pass" );});

module("Module B");test("some other test", function() { expect(1); ok( true, "well" );});

Page 21: jQuery 1.3 and jQuery UI

qUnit Output

Page 22: jQuery 1.3 and jQuery UI

Performance Analysis

Page 24: jQuery 1.3 and jQuery UI

Thank You!✦ John Resig✦ http://ejohn.org/✦ http://twitter.com/jeresig/