brave new world of html5

98
(Brave new world of) HTML5 Chris Mills, Opera Software / Webinale 2011, Berlin, May 31st

Upload: chris-mills

Post on 15-May-2015

3.733 views

Category:

Technology


0 download

DESCRIPTION

In this, my talk for Webinale in Berlin, June 1st 2011, I give an overview of HTML5 history and main features, relating it all back to how possible it is use develop with these new features today. Thanks to Patrick Lauke for allowing me to steal a lot of his slides ;-)

TRANSCRIPT

Page 1: Brave new world of HTML5

(Brave new world of) HTML5

Chris Mills, Opera Software / Webinale 2011, Berlin, May 31st

Page 2: Brave new world of HTML5

Open standards evangelist at OperaHTML5 / CSS3 wrangler

dev.opera.comslideshare.net/chrisdavidmills

Education agitator

Also heavy metal drummer

Page 3: Brave new world of HTML5

...should I use HTML5 today?

Page 4: Brave new world of HTML5

www.textfiles.com/underconstruction

Page 5: Brave new world of HTML5

"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 6: Brave new world of HTML5

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

Page 7: Brave new world of HTML5
Page 8: Brave new world of HTML5

HTML5…without the hype?

Page 9: Brave new world of HTML5

A brief history of HTML5

1999 HTML 4.012000 XHTML 1.0

Page 10: Brave new world of HTML5

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

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

Page 11: Brave new world of HTML5

WHATWGWeb Hypertext Application Technology Working Group

Page 12: Brave new world of HTML5

2007 W3C HTML5 WG

Page 13: Brave new world of HTML5
Page 14: Brave new world of HTML5

HTML5 does not replace HTML 4.01 / XHTML 1.0

Page 15: Brave new world of HTML5

HTML5 has more bling!

Page 16: Brave new world of HTML5

“...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 17: Brave new world of HTML5

HTML4.01 primarily definedmarkup elements

Page 18: Brave new world of HTML5

HTML5 supercedesHTML 4.01, XHTML 1.0and DOM Level 2 HTML

Page 19: Brave new world of HTML5

HTML5 adds/redefines markup elements

header, footer, nav, article …

Page 20: Brave new world of HTML5

HTML5 extendsDOM Level 2

innerHTML / outerHTML getElementsByClassName()

Page 21: Brave new world of HTML5

HTML5 aimed at browser devs

detailed algorithms for processing/error correction

Page 22: Brave new world of HTML5

1. forms2. multimedia3. web apps

Page 23: Brave new world of HTML5

1. forms2. multimedia3. web apps

Page 24: Brave new world of HTML5

improved form elementsbecause the web is more interactive

Page 25: Brave new world of HTML5

jqueryui.com

Page 26: Brave new world of HTML5

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 27: Brave new world of HTML5

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 28: Brave new world of HTML5

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

Page 29: Brave new world of HTML5

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

Page 30: Brave new world of HTML5

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 31: Brave new world of HTML5

1. forms2. multimedia3. web apps

Page 32: Brave new world of HTML5

<bling> ?

Page 33: Brave new world of HTML5

<video>

Page 34: Brave new world of HTML5

Adobe Flash currently most commonvideo delivery mechanism

Page 35: Brave new world of HTML5

<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 36: Brave new world of HTML5

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

Page 37: Brave new world of HTML5

<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 38: Brave new world of HTML5

video as native object● behaves like any other HTML element● keyboard accessibility out-of-the-box

Page 39: Brave new world of HTML5

powerful (simple) API

Page 40: Brave new world of HTML5

controlling <video> with JavaScript

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

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

Page 41: Brave new world of HTML5

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 42: Brave new world of HTML5

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

Page 43: Brave new world of HTML5

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

Page 44: Brave new world of HTML5

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

Page 45: Brave new world of HTML5

HTML5 means all your old dHTML is cool again!

Page 46: Brave new world of HTML5

video formatsthe big debate?

Page 47: Brave new world of HTML5

HTML5 does not specify video container/codec

(same as with images in HTML 4.01)

Page 48: Brave new world of HTML5

MP4/H.264or

Ogg Theoraor

WebM/VP8

Page 49: Brave new world of HTML5

MP4 / H.264

ubiquitous, patent encumbered, licensing/royalties

Page 50: Brave new world of HTML5

Ogg Theora

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

Page 51: Brave new world of HTML5

WebM / VP8

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

Page 52: Brave new world of HTML5

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

<source src="movie.mp4" type="video/mp4" /><source src="movie.webm" type="video/webm" />

<!-- fallback content --></video>

Page 53: Brave new world of HTML5

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

Page 54: Brave new world of HTML5

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

<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 55: Brave new world of HTML5

<audio>

Page 56: Brave new world of HTML5

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 57: Brave new world of HTML5

<canvas>

Page 58: Brave new world of HTML5

canvas = “scriptable images”

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

Page 59: Brave new world of HTML5

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 60: Brave new world of HTML5

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

Page 61: Brave new world of HTML5

mariuswatz.com/works/abstract01js

Page 62: Brave new world of HTML5

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 63: Brave new world of HTML5

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

Page 64: Brave new world of HTML5

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 65: Brave new world of HTML5

github.com/mezzoblue/PaintbrushJS

Page 66: Brave new world of HTML5

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 67: Brave new world of HTML5

html5doctor.com/video-canvas-magic

Page 68: Brave new world of HTML5

www.filamentgroup.com/examples/charting

Page 69: Brave new world of HTML5

canvas accessibility?

Page 70: Brave new world of HTML5

video, audio and canvas on any devicewithout plugins

(Java / Flash / Silverlight not ubiquitous)

Page 71: Brave new world of HTML5
Page 72: Brave new world of HTML5
Page 73: Brave new world of HTML5

1. forms2. multimedia3. web apps

Page 74: Brave new world of HTML5

HTML5 (and friends) haslots more APIs for developers

(for powerful client-side apps)

Page 75: Brave new world of HTML5

isgeolocationpartofhtml5.com

Page 76: Brave new world of HTML5

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 77: Brave new world of HTML5

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 78: Brave new world of HTML5

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 79: Brave new world of HTML5

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

Page 80: Brave new world of HTML5

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 81: Brave new world of HTML5

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

Page 82: Brave new world of HTML5

is it all safe to use, right now?

Page 83: Brave new world of HTML5

www.youtube.com/html5

Page 84: Brave new world of HTML5

caniuse.com

Page 85: Brave new world of HTML5

don't do browser sniffing

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

Page 86: Brave new world of HTML5
Page 87: Brave new world of HTML5

feature-detectionprogressive enhancement, graceful degradation

http://diveintohtml5.org/everything.html

Page 88: Brave new world of HTML5

modernizr.com

Page 89: Brave new world of HTML5

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

Page 90: Brave new world of HTML5

yepnopejs.com

Page 91: Brave new world of HTML5

sublimevideo.net

Page 92: Brave new world of HTML5

www.happyworm.com/jquery/jplayer

Page 93: Brave new world of HTML5

HTML5 as Flashkiller?

Page 94: Brave new world of HTML5

not a question ofHTML5 replacing Flash...

Page 95: Brave new world of HTML5

giving developers a choice!

Page 96: Brave new world of HTML5

...should I use HTML5 today?

Page 97: Brave new world of HTML5

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

Page 98: Brave new world of HTML5

http://[email protected]