HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

106
HTML5 (and friends) Patrick H. Lauke / jsDay / Verona / 11 Maggio 2011 HISTORY, OVERVIEW AND CURRENT STATUS

Transcript of HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

Page 1: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

HTML5 (and friends)

Patrick H. Lauke / jsDay / Verona / 11 Maggio 2011

HISTORY, OVERVIEW AND CURRENT STATUS

Page 2: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

Web Evangelist at Opera

Page 3: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

!javaScriptExpert

Page 4: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

doesn't matter! HTML5 makes things easy

(even for noobs like me)

Page 5: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

...should I use HTML5 today?

Page 6: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

www.textfiles.com/underconstruction

Page 7: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

"there is already a lot of excitement for HTML5, but it’s a little too early to deploy it because we’re running into interoperability issues."

Philippe Le Hegaret, W3C interaction domain leader

blogs.techrepublic.com.com/hiner/?p=6369

Page 8: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

http://www.flickr.com/photos/24374884@N08/4603715307/

Page 9: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

NATIVE HTML5

Page 10: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

HTML5…without the hype?

Page 11: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

A brief history of HTML5

1999 HTML 4.012000 XHTML 1.0

Page 12: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

2004 W3C focus on XHTML 2.0…the future is XML-based!

http://www.flickr.com/photos/craiga/17071467/

Page 13: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

WHATWGWeb Hypertext Application Technology Working Group

Page 14: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

2007 W3C HTML5 WG

Page 15: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011
Page 16: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

HTML5 does not replace HTML 4.01 / XHTML 1.0

Page 17: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

HTML5 has more bling!

Page 18: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

“...extending the language to better support Web applications [...] This puts HTML in direct competition with other technologies[...] , in particular Flash and Silverlight.”

Ian Hickson, Editor of HTML5http://lists.w3.org/Archives/Public/public-html/2009Jan/0215.html

Page 19: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

HTML4.01 primarily definedmarkup elements

Page 20: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

HTML5 supercedesHTML 4.01, XHTML 1.0and DOM Level 2 HTML

Page 21: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

HTML5 adds/redefines markup elements

header, footer, nav, article …

Page 22: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

HTML5 extendsDOM Level 2 HTML

innerHTML / outerHTML getElementsByClassName()

Page 23: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

HTML5 aimed at browser devs

detailed algorithms for processing/error correction

Page 24: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

<b><i>Yo!</b></i>

Page 26: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

1. forms2. multimedia3. web apps

Page 27: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

1. forms2. multimedia3. web apps

Page 28: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

improved form elementsbecause the web is more interactive

Page 29: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

jqueryui.com

Page 30: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

rich form elements without JavaScript

<input type="date"><input type="time"><input type="month"><input type="week"><input type="datetime" … ><input type="range"><input type="number">

<input type="file" multiple>

<input … autofocus><input … autocomplete>

Page 31: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

built-in validation without JavaScript<input … required><input type="tel"><input type="email"><input type="url"><input … pattern="[a-z]{3}[0-9]{3}"><input type="number" min="1" max="5">…

Page 32: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

people.opera.com/patrickl/experiments/forms/newtypes.html

Page 33: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

people.opera.com/patrickl/experiments/forms/validation.html

Page 34: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

validity checking with JavaScriptform.checkValidity()formelement.checkValidity()

formelement.setCustomValidity()

formelement.validity

interface ValidityState { readonly attribute boolean valueMissing; readonly attribute boolean typeMismatch; readonly attribute boolean patternMismatch; readonly attribute boolean tooLong; readonly attribute boolean rangeUnderflow; readonly attribute boolean rangeOverflow; readonly attribute boolean stepMismatch; readonly attribute boolean customError; readonly attribute boolean valid;};

Page 35: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

1. forms2. multimedia3. web apps

Page 36: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

making your site Fonzie compliant...

Page 37: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

<video>

Page 38: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

Adobe Flash currently most commonvideo delivery mechanism

Page 39: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

<object width="425" height="344"><param name="movie"

value="http://www.youtube.com/v/9sEI1AUFJKw&hl=en&fs=1&"></param>

<param name="allowFullScreen" value="true"></param>

<param name="allowscriptaccess" value="always"></param>

<embed src="http://www.youtube.com/v/9sEI1AUFJKw&hl=en&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>

Page 40: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

<video src="video.webm"></video>

Page 41: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

<video src="video.webm" controls autoplay loop preload="none" poster="poster.jpg" width="320" height="240"> <a href="video.webm">Download movie</a></video>

Page 42: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

video as native object

● behaves like any other HTML element● keyboard accessibility out-of-the-box

Page 43: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

powerful (simple) API

Page 44: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

controlling <video> with JavaScript

var v = document.getElementById('player');

v.play();v.pause();v.volume = … ;v.currentTime = … ;…

Page 45: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

events fired by <video>

var v = document.getElementById('player');

v.addEventListener('loadeddata', function() { … }, true)v.addEventListener('play', function() { … }, true)v.addEventListener('pause', function() { … }, true)v.addEventListener('timeupdate', function() { … }, true)v.addEventListener('ended', function() { … }, true)…

Page 46: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

people.opera.com/patrickl/experiments/webm/basic-controls

Page 47: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

people.opera.com/patrickl/experiments/webm/fancy-controls

Page 48: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

people.opera.com/patrickl/experiments/webm/fancy-swap

Page 49: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

HTML5 means all your old dHTML is cool again!

Page 50: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

video formatsthe big debate?

Page 51: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

HTML5 does not specify video container/codec

(same as with images in HTML 4.01)

Page 52: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

MP4/H.264or

Ogg Theoraor

WebM/VP8

Page 53: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

MP4 / H.264

ubiquitous, patent encumbered, licensing/royalties

Page 54: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

Ogg Theora

free and open, no licensing feesnot many tools for it, not web optimised

Page 55: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

WebM / VP8

open and royalty-free, web-optimisedsupport by hardware and software vendors

Page 56: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

providing multiple sources<video controls autoplay poster="…" width="…" height="…">

<source src="movie.mp4" type="video/mp4" /><source src="movie.webm" type="video/webm" /><source src="movie.ogv" type="video/ogg" /><!-- fallback content -->

</video>

Page 57: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

flash fallback for older browsershttp://camendesign.com/code/video_for_everybody

Page 58: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

<video controls autoplay poster="…" width="…" height="…"><source src="movie.mp4" type="video/mp4" /><source src="movie.webm" type="video/webm" /><source src="movie.ogv" type="video/ogg" />

<object width="…" height="…" type="application/x-shockwave-flash" data="player.swf">

<param name="movie" value="player.swf" /><param name="flashvars" value=" … file=movie.mp4" /><!-- fallback content -->

</object>

</video>

Page 59: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

<audio>

Page 60: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

audio...exactly the same as video

<audio src=”music.mp3” controls autoplay … ></audio>

<audio controls autoplay><source src="music.mp3" type="audio/mpeg" /><source src="music.oga" type="audio/ogg" /><!-- fallback content -->

</audio>

formats: MP3 vs Ogg Vorbis (vs WAV)

Page 61: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

<canvas>

Page 62: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

canvas = “scriptable images”

<canvas width="…" height="…"></canvas>

Page 63: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

canvas has standard API methods for drawing

ctx = canvas.getContext("2d");ctx.fillRect(x, y, width, height);ctx.beginPath();ctx.moveTo(x, y);ctx.lineTo(x, y);ctx.bezierCurveTo(x1, y1, x2, y2, c1, c2);

Page 64: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

people.opera.com/patrickl/experiments/canvas/particle/3

Page 65: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

mariuswatz.com/works/abstract01js

Page 66: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

canvas drawing ready-made images

ctx = canvas.getContext("2d");

var logo = new Image();logo.src = 'logo.png';

ctx.drawImage(logo,x1,y1,w1,h1,x2,y2,w2,h2);

or call in an existing image already on the page

Page 67: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

www.splintered.co.uk/experiments/archives/paranoid_0.3

Page 68: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

canvas access to image data array

ctx = canvas.getContext("2d");canvasData = ctx.getImageData(x,y,w,h);

[R,G,B,A,R,G,B,A,R,G,B,A,R,G,B,A, … ]

Page 69: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

www.splintered.co.uk/experiments/archives/canvas-ambilight

Page 70: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

github.com/mezzoblue/PaintbrushJS

Page 71: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

canvas also works with video

ctx = canvas.getContext("2d");v = document.getElementById('player');

ctx.drawImage(v,x1,y1,w1,h2,x2,y2,w2,h2);

grab currently displayed frame (update as appropriate)

Page 72: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

html5doctor.com/video-canvas-magic

Page 73: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

media.chikuyonok.ru/ambilight

Page 74: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

www.filamentgroup.com/examples/charting

Page 75: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

canvas accessibility?

Page 76: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

video, audio and canvas on any devicewithout plugins

(Java / Flash / Silverlight not ubiquitous)

Page 77: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011
Page 78: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011
Page 79: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

1. forms2. multimedia3. web apps

Page 80: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

HTML5 (and friends) haslots more APIs for developers

(for powerful client-side apps)

Page 81: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

isgeolocationpartofhtml5.com

Page 82: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

geolocationnavigator.geolocation.getCurrentPosition(success, error);navigator.geolocation.watchCurrentPosition(success, error);

function success(position) {/* where's Wally? */var lat = position.coords.latitude;var long = position.coords.longitude;...

}

Page 83: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

offline detectionwindow.addEventListener('online', function(){ … }, true);window.addEventListener('offline', function(){ … }, true);

…however, currently unreliable!

Page 84: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

application cache<html manifest=”blah.manifest”>

CACHE MANIFEST# send this with correct text/cache-manifest MIMEimages/sprites.pngscripts/common.jsscripts/jquery.jsstyles/global.css

NETWORK:# never cached (apart from normal caching mechanism)onlineonly.css

FALLBACK:# pattern matching. fallback file will also be cachedimages/ images/not-offline.png

Page 85: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

data storage

cookies and their limitations...

document.cookie = 'key=value; expires=Thu, 15 Feb 2010 23:59:59 UTC; path=/'…

/* convoluted string operations go here … */

Page 86: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

localStorage/sessionStoragelocalStorage.setItem(key, value);localStorage.getItem(key);localStorage.clear();localStorage.key = value;if (localStorage.key == '…') { … }…

localStorage – persistent per domainsessionStorage – current URL and window in session

only string data – store serialised objects

Page 87: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

WebSQL

relational DB / SQL in browser

var db =openDatabase(dbName, version, displayName, expectedSize);

db.transaction(function(tx) {tx.executeSql(sqlStatement, [], function (tx, result) {

/* do something with the results */});

});

not being developed further (IE/Mozilla prefer IndexedDB) – nonetheless available right now in Opera+WebKit!

Page 88: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

etcFile API, Web Workers, History API, Web Messaging,Drag and Drop, Server-Sent Events…

Page 89: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

is it all safe to use, right now?

Page 90: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

www.youtube.com/html5

Page 91: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

caniuse.com

Page 92: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

don't do browser sniffing

http://www.flickr.com/photos/timdorr/2096272747/

Page 93: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011
Page 94: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

feature-detectionprogressive enhancement, graceful degradation

http://diveintohtml5.org/everything.html

Page 95: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

feature-detection for audio/video

if (!!document.createElement('video').canPlayType;) { … }

if (!!document.createElement('audio').canPlayType;) { … }

Page 96: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

modernizr.com

Page 97: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

patching older browsersgithub.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills

Page 98: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

yepnopejs.com

Page 99: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

sublimevideo.net

Page 100: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

www.happyworm.com/jquery/jplayer

Page 101: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

HTML5 as Flashkiller?

Page 102: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

not a question ofHTML5 replacing Flash...

Page 103: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

giving developers a choice!

Page 104: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

...should I use HTML5 today?

Page 105: HTML5 (and friends) - History, overview and current status - jsDay Verona 11.05.2011

“The future is already here – it's just not very evenly distributed”

William Gibson