jqueryto: state of jquery march 2013

45
The State of jQuery Dave Methvin President, jQuery Foundation March, 2013

Upload: dmethvin

Post on 05-Dec-2014

1.284 views

Category:

Documents


1 download

DESCRIPTION

 

TRANSCRIPT

Page 1: jQueryTO: State of jQuery March 2013

The State of jQuery

Dave Methvin

President, jQuery Foundation

March, 2013

Page 2: jQueryTO: State of jQuery March 2013

Jan 2006: The birth of jQuery

How It All Started

Page 3: jQueryTO: State of jQuery March 2013

Feb 2013: jQuery core is used by 64

percent of the top 10,000 sites

Seven Years of Good Luck

Page 4: jQueryTO: State of jQuery March 2013

• Created in March 2012

The jQuery Foundation

Page 5: jQueryTO: State of jQuery March 2013

• Created in March 2012

The jQuery Foundation

Page 6: jQueryTO: State of jQuery March 2013

• Created in March 2012

• Coordinates the work of jQuery team

members and volunteers

The jQuery Foundation

Page 7: jQueryTO: State of jQuery March 2013

• A non-profit organization

o Volunteer board of directors

o Volunteer president (thats me)

o A few paid staff, mainly devs/ops

• Funded by o Conferences

o Donations – http://jquery.org/donate

o Memberships

o YOU or your company can be a member

http://jquery.org/join

The jQuery Foundation Is...

Page 8: jQueryTO: State of jQuery March 2013

• Founding Members

jQuery Foundation

Page 9: jQueryTO: State of jQuery March 2013

• Gold Members

jQuery Foundation

Page 10: jQueryTO: State of jQuery March 2013

• Organize/fund work on the projects

• Advocate for web developer needs

o W3C web standards

o ECMA TC39 JavaScript standards

• Run two US conferences annually

• License conferences worldwide

The jQuery Foundation's Work

Page 11: jQueryTO: State of jQuery March 2013

• http://github.com/jquery

• jQuery Core

• jQuery UI

• jQuery Mobile

• Sizzle selector engine

• QUnit unit test framework

• jQuery Migrate plugin

• TestSwarm CI testing

• Documentation sites

jQuery Foundation Projects

Page 12: jQueryTO: State of jQuery March 2013

• It’s all on Github – not just the code

• File an issue when you see a problem

• Make pull requests against docs

• Join our forum and share knowledge

Join The Community

Page 13: jQueryTO: State of jQuery March 2013

• jQuery 1.9 vs. 2.0

o jQuery 1.x still supports IE 6/7/8

o jQuery 2.x supports modern browsers

o The two versions stay in API sync

o Both branches maintained by the team

• Heavily publicized changes during 2012

• Released several public betas

• Shipped jQuery 1.9 in January

The jQuery Core Library Plan

Page 14: jQueryTO: State of jQuery March 2013

Far too many people

are using "latest"

versions in live sites!

NEVER HOTLINK:

http://code.jquery.com/jquery-latest.js

http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js

What We Learned (the Hard Way)

Page 15: jQueryTO: State of jQuery March 2013

jQuery 1.9: Users Love It!

Page 16: jQueryTO: State of jQuery March 2013

• Identifies things your code is doing that

jQuery 1.9/2.0 don't support anymore

• Actually changes jQuery back to pre-1.9

behavior so older code just works

• Lets you use jQuery 1.9/2.0 with code

that hasn't been upgraded yet

• Documentation gives advice on how to

remediate the issue

jQuery Migrate Plugin

Page 17: jQueryTO: State of jQuery March 2013

jQuery Migrate Example

Page 18: jQueryTO: State of jQuery March 2013

• Shown in the uncompressed version

• Problem and solutions documented

jQuery Migrate Warnings

Page 19: jQueryTO: State of jQuery March 2013

How Do I Fix This?

Page 20: jQueryTO: State of jQuery March 2013

Include the minified version of the plugin

and no warnings appear

Shut-Up-and-Fix-It Mode

Page 21: jQueryTO: State of jQuery March 2013

• Removed $.browser

• Removed .live()

• Fixed $.parseJSON

What We Broke Fixed, and Why

Page 22: jQueryTO: State of jQuery March 2013

• Usually the wrong inference

• Often assumes future browsers and

versions will be broken the same way

• Horribly misused and misunderstood

Why $.browser Deserves To Go

Page 23: jQueryTO: State of jQuery March 2013

Chrome added focusin/out two years ago!

Why You Don't Assume Browsers

Page 24: jQueryTO: State of jQuery March 2013

Opera just announced their future

products will be based on the WebKit

engine, not their own Presto engine.

Browser Name is Only a BRAND

Page 25: jQueryTO: State of jQuery March 2013

• IE can emulate older versions via <meta name="X-UA-Compatible“ …>

• Can be accidentally lobotomized via that

confounded Address Bar button

• Browser version in the UA string does not

represent the real version

Internet Explorer's Disguises

The Enemy!

Page 26: jQueryTO: State of jQuery March 2013

Who Else Used $.browser?

Page 27: jQueryTO: State of jQuery March 2013

Who Else Used $.browser?

Page 28: jQueryTO: State of jQuery March 2013

Please Don't Do This ...

Page 29: jQueryTO: State of jQuery March 2013

Not fixing the problem, no code attribution

... copy/pasta is bad!

Page 30: jQueryTO: State of jQuery March 2013

Use jQuery Migrate or (better) Modernizr!

... copy/pasta is bad!

Page 31: jQueryTO: State of jQuery March 2013

• It's like global variables, but for events

• Every event that occurs must bubble to document before it can be processed

• Processing events can be expensive,

especially on deep documents

• Still easy to process events globally: o $(document).on("click", "a", linkyClicky);

What's Wrong With .live()?

Page 32: jQueryTO: State of jQuery March 2013

• Doesn't work well on iPhone/iPad!

• iOS doesn't bubble touch events all the way to document

• Delegated touch events must be processed below the <body> element

Letting all events bubble to document destroys the usefulness of the event

propagation model

What's Wrong With .live()?

Page 33: jQueryTO: State of jQuery March 2013

Original line: $(".dialog .close").live("click", ...

Direct replacement (poor): $(document).on("click", ".dialog .close" ...

Optimized replacement: $(".dialog").on("click", ".close", ...

Optimize Your Selectors

Page 34: jQueryTO: State of jQuery March 2013

The Bug: • Before 1.9, $.parseJSON("") returned

null but it's not valid JSON

The Fix: • In 1.9, $.parseJSON("") is an error

JSON Should Be JSON

Page 35: jQueryTO: State of jQuery March 2013

• We called invalid JSON invalid.

• We're also out of coffee.

The Result: PANIC

Page 36: jQueryTO: State of jQuery March 2013

In jQuery, every change is

a breaking change for

some poor developer.

The Moral of the Story

Page 37: jQueryTO: State of jQuery March 2013

Nobody tries the jQuery

alpha and beta builds.

The Other Moral of the Story

Page 38: jQueryTO: State of jQuery March 2013

• How Big?

Big News!

Page 39: jQueryTO: State of jQuery March 2013

• How Big?

Big News!

Page 40: jQueryTO: State of jQuery March 2013

• Released yesterday -- please try it!

• Custom builds can shrink size

• Bare-bones selector engine option

o Basically, just querySelectorAll

• How small?

o Normal build: 28KB minified and gzipped

o Blog example: 17KB

o Tiniest build: 14KB

Big News: jQuery 2.0 Beta 2

Page 41: jQueryTO: State of jQuery March 2013

Making a public web site?

You don't need 2.0 right now!

jQuery 2.0 is a good fit for:

• Chrome or Firefox plugins

• node.js apps (jsdom, Cheerio)

• Windows 8 Store ("Modern/Metro") apps

• PhoneGap (iPhone/Android/BlackBerry)

• Apps using UIWebKit or WebBrowser

jQuery 2.0: README.NOW

Page 42: jQueryTO: State of jQuery March 2013

• The jQuery team supports both 1.9 and

2.0; there isn't a problem of using an

"unsupported version"

• Since 1.x/2.x APIs are the same, there is

no problem in using 1.x exclusively on a

public web site -- it's recommended

• You can detect platforms and include 1.9

or 2.0, but beware of your code or

plugins using undocumented semantics!

jQuery 2.0 is Forward Looking

Page 43: jQueryTO: State of jQuery March 2013

EcmaScript 5 is was the 2.0 baseline

Old Android Browsers Lack ES5

:-(

(-:

Page 44: jQueryTO: State of jQuery March 2013

Old WebKit is the New Old IE

Page 45: jQueryTO: State of jQuery March 2013

Email: [email protected]

Twitter: @davemethvin

GitHub: @dmethvin

IRC (Freenode): DaveMethvin #jquery-dev

Questions?