SlideShare une entreprise Scribd logo
1  sur  201
Télécharger pour lire hors ligne
HTML 5
What is HTML5?
“Specification that defines the 5th major
revision of the core language of the
World Wide Web: HTML.”
World Wide Web Consortium
What is HTML5?
+ +
What is HTML5?
New Cool
Who’s in charge?
WHATWGW3C
HTML WG
Browser
Vendors
Who’s in charge?
Ian Hickson
Editor of HTML5 specification
Standardisation
Editor`s Draft
First Public
Working Draft
Last Call
Candidate
Recommendation
Recommendation
State of HTML5
“So we opened a mailing list called the WHATWG to continue work
on Web Forms 2.0 in public, and later that year started a new draft
called Web Applications 1.0 into which we put many features aimed
at writing Web apps, including a new version of HTML that we
jokingly called HTML5…”
2004
Ian Hickson
State of HTML5
State of HTML5
Early expectations
2012 – W3C Candidate Recommendation
W3C Recommendation
2020?
State of HTML5
Reality
2012 – W3C Candidate Recommendation
W3C Recommendation
2014
State of HTML5
Old browsers (Q1 2013)
More on:
www.html5test.com
~ 33%
IE 6-8
FF 3-3.6
OP 9x
State of HTML5
Mobile Platforms
Various degree of support in mobile operating systems.
iOS Android Window Phone BlackBerry
State of HTML5
jQuery 2.0
Drops support of legacy browsers
State of HTML5
“JQuery 2.0 now has more patches and
shims for Chrome, Safari, and Firefox than
for Internet Explorer.”
Dave Methvin
President, jQuery Foundation
State of HTML5
Web
Native
Classic
Web
Desktop
(PC)
RIA
“HTML5”
Web
State of HTML5
Already moved to HTML5
State of HTML5
“When I`m introspective about last few years I think the
biggest mistake we made as a company was betting too
much on HTML5 as opposed to native… because it just
wasn`t there. … We burned two years. It`s really painful.”
Mark Zuckerberg
SEO of Facebook, September 2012
Goals of HTML5
Native Multimedia
Programmatic Context
Enhanced Web Semantics
“Plug-in free” Development
Goals of HTML5
Adobe Flash
What is wrong with Adobe Flash?
Lot of security vulnerabilities
Low performance on older machines
Disallowed on mobile devices
Requires user to install separate plug-in
Goals of HTML5
Silverlight
What is wrong with Silverlight?
Tied to Windows
Requires user to install separate plug-in
Historical dislike of Microsoft
State of HTML5
Be pragmatic
Stability
Use what works
today
Granularity
Use what you need
Rationality
Web Standards not
always fit
State of HTML5
“And it`s not that HTML5 is bad. I`m actually, on long-term,
really excited about it. One of the things that`s interesting
is we actually have more people on a daily basis using
mobile Web Facebook than we have using our iOS and
Android apps combined. So mobile Web is a big thing for
us.”
Mark Zuckerberg
SEO of Facebook, September 2012
HTML5
How to take advantage of HTML5?
You already, DO!
How to enable HTML5 standards mode in browsers?
<!DOCTYPE html>
Place this on top of your document. No DTD!
HTML5
Tools
Visual Studio 2012 with Web
Essentials.
For .NET Developers
Expression Web
For non .NET Developers
Adobe Dreamweaver
Aptana Studio
JetBrains WebStorm
HTML5
Storage API`s
Web SQL IndexedDBWeb Storage
Local Storage Session Storage
Web Storage
Local Storage
Persistent store for up to 5 MiB of data
on users local machine (10 MiB for IE)
Essential details
Never transferred to server side (no-
cookies)
Accessible from JavaScript
Store for Key-Value pairs of strings
Important notes
Objects should be stringifyed prior to
saving to localStorage
It is allowed for browser to clear
localStorage without user permission
Go to full
specification
Web Storage
Session Storage
Non-Persistent store for up to 5 MiB of
data on users local machine (10 MiB for IE)
Essential details
Go to full
specification
Data accessible only during current
session (browser tabs)
Shares API with localStorage
Web StorageLocal Storage & Session Storage
setItem(key, value) - to set something to the browsers storage
API
Go to full
specification
getItem(key) – to get value from storage
removeItem(key) – to remove item from storage
clear() – to clear storage
Web SQLEssentials
What`s is Web SQL?
Go to full
specification
Web SQL Database is a web page API for storing data in databases that
can be queried using a variant of SQL
Full power of relational database on client side
Support for transactions
Specification based on SQLite
Synchronous and asynchronous API
Web SQL
What`s the state of Web SQL?
Go to full
specification
Deprecated! Working Group does not intend to maintain it further.
What`s wrong with Web SQL?
All interested implementers have used the same SQL backend (SQLite), but
W3C need multiple independent implementations to proceed along a
standardization path.
Essentials
Web SQL
Go to full
specification
openDatabase – opens or creates database
API
transaction – creates transaction
executeSql – used for executing SQL read and write statements
IndexedDBEssentials
What`s is IndexedDB?
Go to full
specification
IndexedDB is an API for client-side storage of significant amounts of
structured data
It`s an object store, but it`s not a relational database.
Support for transactions
Support for indexes
Synchronous and asynchronous API
IndexedDBEssentials
Specific terms of IndexedDB
Go to full
specification
Database comprises one or more object stores which hold the data
stored in the database
Object Store is the primary storage mechanism for storing data in a
database
Transaction is used to interact with the data in a database
Request represents one read or write operation
HTML5
Native multimedia
Multimedia
Video Audio
Native Multimedia
Essentials
Abstract MediaElement
Audio & Video has common API
First class citizen of DOM
Application Programming Interface
Native Multimedia
Programmatic Context
Go to full
specification
Events
Network-
related
Buffering
level
Playback control and
feature detection
Native Multimedia
Events
Go to full
specification
Loadstart Progress Suspend Abort
Error Emptied Stalled
Network-related
loadedmetadata loadeddata waiting
playing canplay canplaythrough
Buffering level
Native Multimedia
JavaScript & CSS
Go to full
specification
First-class DOM citizen and can be styles with CSS3
Exposes properties and functions to JavaScript
Properties Functions
playbackRate
volume
muted
networkState
readyState
currentTime play
pause
load
Native Multimedia
Format Support
Go to full
specification
“…regarding codecs for <video> and <audio> in HTML5, I
have reluctantly come to the conclusion that there is no
suitable codec that all vendors are willing to implement
and ship.”
Ian Hickson
Audio
Essentials
Built in tag <audio> for embedding audio player
Natively support – require no plug-ins
Out of the box user interface
API for controlling audio playback
Go to full
specification
Audio
Essentials
Go to full
specification
Attributes of <audio> tag
Src - media content source
Preload - attribute is intended to provide a hint to the user agent about what the
author thinks will lead to the best user experience.
None – do not preload
Metadata – preload metadata only
Auto – let browser decide
Controls – specifies whether built-in controls visible or not
Loop - indicates that the media element should to seek back to the start
Crossorigin - indicates that audio file is being served from different origin
Audio
Essentials
Go to full
specification
Tools of the Devil
Loop - indicates that the media element should to seek back to the start
Autoplay - indicates that the media element should automatically start
playback once its fully loaded
Audio
Look & Feel
Go to full
specification
How does it looks like? What the markup is?
<audio controls="controls">
<source src="song.ogg" type="audio/ogg" />
<source src="song.mp3" type="audio/mpeg" />
Your browser does not support the audio element.
</audio>
Audio
Programmatic Context
Go to full
specification
play - to play audio
API
pause – to pause audio
canPlayType(type) – determines whether type supported by user agent
buffered – attribute that specifies the start and end time of the buffered
part of the file
Audio
Format Support
Go to full
specification
MP3 WebM OGG AAC
Video
Essentials
Built in tag <video> for embedding video player
Natively support – require no plug-ins
Out of the box user interface
API for controlling video playback
Go to full
specification
Video
Video formats
Go to full
specification
MPEG4
+
WebM
+
OGG
+
Video
Essentials
Go to full
specification
Attributes of <video> tag
Src - media content source
Preload - attribute is intended to provide a hint to the user agent about what the
author thinks will lead to the best user experience.
None – do not preload
Metadata – preload metadata only
Auto – let browser decide
Controls – specifies whether standard controls visible or not
Poster – image to show while no video data is available
Video
Look & Feel
Go to full
specification
How does it looks like? What the markup is?
<video width="320" height="240" controls="controls">
<source src="movie.mp4" type="video/mp4" />
<source src="movie.ogg" type="video/ogg" />
Your browser does not support the video tag.
</video>
Video
Issues
Go to full
specification
Fullscreen playing
Live Streaming
Patchy browser support
Canvas
Essentials
Go to full
specification
HTML5 element that allows for dynamic, scriptable rendering of 2D
shapes and bitmaps
Immediate mode rendering
Rich API: 45 methods, 21 attributes
Future plans for 3D rendering
Canvas
Go to full
specification
API
Application Programming Interface
State
Transformations
Compositing
Color & Styles
Line caps/joins
Shadows
Rectangles
Path API
Text
Pixel manipulation
Focus management
Drawing images
Canvas
History
Go to full
specification
Developed as platform for
OSX Dashboard Widgets
in 2004
Canvas
Use cases
Go to full
specification
Data visualization
Canvas
Use cases
Go to full
specification
Animated graphics
Canvas
Use cases
Go to full
specification
Web Applications
Canvas
Use cases
Go to full
specification
Games
Canvas
Markup
Go to full
specification
What the markup is?
<canvas width=‘800’ height=‘600’>
Your browser doesn`t support canvas.
</canvas>
Canvas
Coordinate System
Go to full
specification
(0, 0) X
Y
Canvas
Rendering Context
Go to full
specification
2D Rendering
Context
Everything is drawn onto 2D
rendering context that is tied to
Canvas instance
Canvas
Rendering Context
Go to full
specification
Context instance can be preserved
and passed around the app
How to get context?
var canvas = document.getElementById(‘canvas’)
var context = canvas.getContext(‘2d’)
Canvas
Drawing Model
Go to full
specification
How to change color?
var canvas = document.getElementById(‘canvas’)
var context = canvas.getContext(‘2d’)
context.fillStyle = ‘black’;
context.strokeStyle = ‘white’;
Canvas
Drawing Model
Go to full
specification
fillRect - draws a rectangle using current fill style
Simple shapes
strokeRect – draws the outline of a rectangle using the current stroke style
clearRect – clears all pixels within the given rectangle
Canvas
Drawing Model
Go to full
specification
Complex shapes
A new patch should be created for each complex shape
Paths are a list of subpath
Subpaths are one or more points connected by straight or curved lines
Rendering context has reference to current active path
Canvas
Drawing Model
Go to full
specification
Complex shapes
beginPath – resets the current path
closePath – closes the current subpath and starts a new one
fill – fills the subpaths with the current fill style
stroke – outlines the subpaths with the current stroke style
Canvas
Drawing Model
Go to full
specification
Complex shapes
lineTo – draws a straight line from the previous point
rect – adds a new closed rectangular subpath
arc – adds a subpath along the circumference of the described circle,
withing the angles defined
arcTo – adds a subpath connecting two points by an arc of the defined
radius
Canvas
Drawing Model
Go to full
specification
Transformations
Affects shapes and paths drawn after the transformation
Shorthand methods for translation, scaling, rotation
Transformation matrices are allowed
Canvas
Drawing Model
Go to full
specification
Transformations
translate – moves coordinate system by specified offset
rotate – rotates coordinate system by specified angle
scale – scales coordinate system by specified factor
transform – multiplies current transformation matrix with specified one
setTransform – sets transformation matrix directly
Canvas
Drawing Model
Go to full
specification
ctx.shadowOffsetX = 10;
ctx.shadowOffsetY = 10;
ctx.shadowBlur = 10;
ctx.shadowColor = "rgba(0, 0, 0, 1)";
ctx.fillText(“Winning!”, 10, 25);
// All future operations will also have a shadow
ctx.strokeRect(0, 0, 115, 40);
All Canvas attributes are global – they effect all operations drawn next.
Canvas
Drawing Model
Go to full
specification
The current values of the following attributes:
strokeStyle, fillStyle, globalAlpha, lineWidth, lineCap,
lineJoin, miterLimit, shadowOffsetX, shadowOffsetY,
shadowBlur, shadowColor, globalCompositeOperation,
font, textAlign, textBaseline.
You can save and restore:
The current transformation matrix.
The current clipping region.
Canvas
State Management
Go to full
specification
ctx.save();
ctx.shadowOffsetX = 10;
ctx.shadowOffsetY = 10;
ctx.shadowBlur = 10;
ctx.shadowColor = "rgba(0, 0, 0, 1)";
ctx.fillText(“Winning!”, 10, 25);
ctx.restore();
// All future operations will NOT have a shadow
ctx.strokeRect(0, 0, 115, 40);
Use save() and restore() to scope the attribute
Canvas
Composition
Go to full
specification
Compositing it the control of transparency and layering of objects
Controlled by globalAlpha and globalCompositeOperation
attributes
Canvas
Composition
Go to full
specification
Canvas
Drawing Model
Go to full
specification
Firefox, Opera and Internet Explorer follow the drawing model as
described in the spec.
Safari and Chrome have a slightly different drawing model behavior.
DO: Check if you’re composition is impacted by this interoperability
issue.
Canvas
Performance
Go to full
specification
Not all operations were made equal. Some are more expensive than
others
Shadows, clipping and composition operations are more expensive as
they require an additional intermediate.
DON’T: Create thousands of small objects with clipping, shadows or
compositions effects.
Canvas
Security Model
Go to full
specification
Canvas allows reading and writing pixels to the screen
You can also save the Canvas to a file via toDataURL()
Canvas PNG File
Canvas also allows drawing cross-domain images/videos
However, it has built-in security protection against third-parties saving
cross-domain pixels
Canvas
Security Model
Go to full
specification
Canvas
PNG File
Canvas
Security Model
Go to full
specification
Canvas has a concept of origin-clean flag.
origin-clean is set false if a cross-domain IMG or VIDEO is used.
A SECURITY_ERR exception is raised, if one tries to save the
Canvas pixels if the Canvas origin-clean is false:
toDataURL()
getImageData()
Animation Frame API
Essentials
Go to full
specification
API for getting precise animation updates
User Agent schedules updates in sync with internal redraw routines
Automatic management of update time and low-power mode
Animation Frame API
Go to full
specification
requestAnimationFrame – requests repaint callback to be scheduled
API
cancelAnimationFrame – cancels repaint callback request
HTML5
Media Capture
User Media
API
HTML Media
Capture
HTML Media Capture
Essentials
Native media capture mechanism
Extends file input
Allows to capture audio, video and photo
HTML Media Capture
Markup
What the markup is?
<input type="file" accept="image/*" capture="camera" />
<input type="file" accept="audio/*" capture="microphone" />
<input type="file" accept="video/*" capture="camcorder" />
Media format controlled by
accept attribute
Media type controlled by
capture attribute
User Media API
Essentials
API that allows to capture media streams
Designed to interoperate with related specs
Allows to capture audio, video and photo
User Media API
Essentials
High level abstraction for streaming data
Can be passed around to different APIs
Contains audio and video tracks
Media Stream
Media Stream Track
High level abstraction for media stream source
User Media API
Media Stream
User Media API
Programmatic Context
Go to full
specification
getUserMedia - to start capturing media stream
API
HTML5
Audio Processing
Web Audio
API
Audio Data
API
JavaScript
DSP
JavaScript DSP
Essentials
Byte-level manipulations with encoded audio data
Getting audio data via XMLHttpRequest or File API
Requires knowledge of DSP and audio formats encoding
Extension: Firefox allows access to PCM data
Web Audio API
Why?
<audio> hides the steps of loading, decoding and playing
No standard way to access raw PCM data
No fine-grained timing
No concept of position and direction of sources and listeners
Hard to analyze and visualize data on the fly
Web Audio API
Essentials
High-level API for processing and synthesizing audio
Gives fine grained control over audio processing and playback
Web Audio API
Real-time processing
and synthesizing audio
Capabilities
An audio pipeline and routing system
for effects and filters
Web Audio API
Access to raw PCM data
Capabilities
Web Audio API
Precise scheduling of
audio playback
Capabilities
Web Audio API
Audio Context
Abstract representation of audio
signal graph and connections
between AudioNodes
Web Audio API
Audio Context
API
destination – audio node that represents actual hardware
sampleRate – the sample rate at which Audio Context handles audio
currentTime – time in seconds tied to hardware clock
listener – an audio listener that is used for 3D spatialization
Web Audio API
Audio Node
Build block of audio graph
Audio node represents
Source
Destination
Intermediate processing module
Set of predefined Audio Nodes as well as ScriptProcessorNode
Web Audio API
Audio Node
AudioDestinationNode AudioBufferSourceNode MediaElementAudioSourceNode
MediaStreamAudioSourceNode MediaStreamAudioDestinationNode ScriptProcessorNode Audio Effect Nodes
Web Audio API
Audio Buffer
Represents in-memory audio asset
Contains IEEE 32-bit linear PCM with a nominal range of -1 -> +1
Contains one or more channels
Typically expected that length of PCM data would be less than a minute
Long audio tracks can be served via MediaElementAudioSourceNode
HTML5
3D
WebGL
Image-based 3D
CSS3 3D
TransformsSoftware rendering
on Canvas
HTML5
Image-based 3D
Set of prerendered images
High degree of browser support
Terrific amount of data to load
No client side customizations
Image-based 3D
Image-based 3D
Fast image switches may cause flickering
Rendering to Canvas may give significant performance boost
HTML5
Software Rendering
Rendering and computations are made on CPU
Manual manipulations with Pixel and Vertex data
Canvas as rasterization surface
Software Rendering
Performance
Software rendering is inherently slow
Good enough for simple scenes
Mobile devices are still a concern
HTML5
CSS3 Transforms
Display-time transformations of any HTML content
transforms do not affect layout
3D Transforms
translate, scale, rotate, skew in X, Y & Z
perspective
CSS3 Transforms
Essentials
Rendering and computations are made on GPU
Applies to any DOM element
Declarative and programmatic control
HTML5
CSS Custom Shaders
User supplied program for GPU programming
Executes in parallel
Source of awesome visual effects
Programmed in GLSL
CSS Custom Shaders
Showcase
CSS Custom Shaders
Rendering Pipeline
CSS Custom Shaders
Types
Fragment
Shader
Vertex
Shader
CSS Custom Shaders
Fragment Shader
GPU program for pixel color manipulation
The result is a pixel color
Executes in parallel on GPU infrastructure
Currently there is no way to set via gl_FragColor
Fragment Shader
Sample
precision mediump float;
void main() {
float r = 1.0;
float g = 1.0;
float b = 1.0;
float a = 1.0;
css_ColorMatrix = mat4( r, 0.0, 0.0, 0.0,
0.0, g, 0.0, 0.0,
0.0, 0.0, b, 0.0,
0.0, 0.0, 0.0, a );
}
CSS Custom Shaders
Vertex Shader
Responsible for mesh deformations
The result is a vertex position
Executes in parallel on GPU infrastructure
Vertex Shader
Sample
precision mediump float;
attribute vec4 a_position;
uniform mat4 u_projectionMatrix;
void main() {
gl_Position = u_projectionMatrix * a_position;
}
Projection matrix is supplied by a
web browser.
a_position stores vertex position
CSS Custom Shaders
Syntax
#myelement {
filter: custom( vertex-shader
[ fragment-shader]
[,vertex-mesh]
[,params]);
}
How to apply shader?
CSS Custom Shaders
Vertex Creation
#myelement {
filter: custom( vertex-shader
[ fragment-shader]
,4 5
[,params]);
}
How to apply shader?
CSS Custom Shaders
Uniforms
#myelement {
filter: custom( vertex-shader
[ fragment-shader]
,4 5
, amount 0);
}
CSS
precision mediump float;
uniform float amount;
void main(){
}
Fragment Shader
WebGL
Essentials
It is a software library that extends the capability of the JavaScript
to allow it to generate 3D graphics
Uses canvas as rendering surface
Based on OpenGL ES 2.0
WebGL
Standard
WebGL
Support
“We believe that WebGL will likely become an ongoing
source of hard-to-fix vulnerabilities. In its current form,
WebGL is not a technology Microsoft can endorse from a
security perspective.”
Microsoft
June 16, 2011
WebGL
Support
“I agree with Microsoft’s assessment that WebGL is a
severe security risk. The gfx driver culture is not the
culture of security.”
John Carmack
Co-founder of Id Software, June 2011
WebGL
Architecture
Typed Arrays
Essentials
Efficient way to pass data into API`s
C-like arrays
Memory can be passed directly to native API`s
Typed Arrays
Array Buffer
Abstract representation of binary data
Serves as a data-source for typed arrays
Integrated with other HTML API`s
Typed Arrays
Array Buffer View
Int8Array Uint8Array Int16Array Uint16Array Int32Array
Uint32Array Float32Array Float64Array Uint8ClampedArray
Typed Arrays
Data View
Simplifies manipulations with heterogeneous types
Supports big and little endian
Be careful with alignment
Typed Arrays
Interoperability
WebGL Canvas 2D File API
Web
Sockets
XHR2
Media
Source
Transferable objects
Same Origin Policy
Go to full
specification
Security
Browser-level Firewall
Prohibits sending security sensitive information to foreign locations
Prohibits read of resources from foreign origin
Primary security barrier against XSS and Cookie stealing attacks
What is same origin policy?
Same Origin Policy
Go to full
specification
Security
What origins are foreign?
http://www.example.com
Same protocol and host but different port
http://www.example.com:81
Different protocol
https://www.example.com
Different host
http://en.example.com
Web Messaging
Essentials
Go to full
specification
Mechanism for cross-document communication
Support for cross-origin communication
API for exchanging plain text messages and structured data
What is Web Messaging?
Web Messaging
Communication
Go to full
specification
Window
object
Message
Channel
Web Messaging
Essentials
Go to full
specification
The end of iframe hacks!
Web Messaging
API
Go to full
specification
postMessage() – to post message to window
Message event – event raised when new message arrived
Web Workers
Go to full
specification
JavaScript is inherently single threaded
Asynchronous through single message loop
No concurrency, no thread synchronization
Motivation
Web Workers
Issue
Go to full
specification
“[JavaScript] that executes in whole seconds is probably
doing something wrong...”
Brendan Eich
Creator of JavaScript,
Mozilla Foundation
Web Workers
Effect
Go to full
specification
Web Workers
Old-school solutions
Go to full
specification
Partition
work with
timers
Offload
work to
server
Web Workers
Essentials
Go to full
specification
JavaScript native ‘threading’ mechanism
True parallelism
Designed to be long-lived
High startup cost performance and memory cost
What are Web Workers?
Web Workers
Essentials
Go to full
specification
Loaded from separate file or Blob
Communication with parent script through messages and events
Can be terminated from inside and outside
Due to their multi-threaded behavior, web workers only has access to a
subset of DOM and BOM features
How it works?
Web Workers
Scope
Go to full
specification
The navigator object
The location object (read-only)
XMLHttpRequest
setTimeout(), setInterval()
The application cache
Importing external scripts using the importScripts() method
Spawning other Web Workers
Features Available to Workers
Web Workers
Scope
Go to full
specification
DOM and BOM
window object
document object
parent object
Features Unavailable to Workers
Web Workers
Types
Go to full
specification
Dedicated Shared
Web Workers
Transferable Objects
Go to full
specification
Structured data can be passed without copying
Huge performance win
Supported structured objects:
ArrayBuffer
MessagePort
CanvasProxy
Web Workers
Transferable Objects
Go to full
specification
HTML5
Go to full
specification
Real-time Communications
HTTP protocol has one request – one resource semantics
No built-in mechanism for Push Notifications
Semi-duplex communications
Overhead of HTTP headers
Real-time
Go to full
specification
Use cases
Live feeds
Real-time
Go to full
specification
Use cases
Multiplayer games
Real-time
Go to full
specification
Use cases
Live sync applications
Real-time
Go to full
specification
Workarounds
Polling Comet
Real-time
Go to full
specification
Polling
Periodic HTTP requests
High server workload
High latency
High degree of support across different browsers
Polling
Go to full
specification
Interaction diagram
Polling
Go to full
specification
Network throughput
Real-time
Go to full
specification
Comet
Periodic long-lived HTTP requests
Reduced traffic
Reduced server workload
Overhead of HTTP headers
Possible difficulties with proxies and load balancers
Comet
Go to full
specification
Interaction diagram
Comet
Go to full
specification
Types
Long
polling
HTTP
Streaming
Web Sockets
Go to full
specification
Essentials
Full-duplex socket connection
Web Socket protocol v13 (RFC 6455) instead of HTTP
Uses HTTP for connection establishment
Low-latency client-server communication technology
Web Sockets
Go to full
specification
Connection Establishment
Runs via port 80/443 to simplify firewalls traversal
Pseudo schemes: ws, wss
Connection established by “upgrading” from HTTP to WebSocket
protocol
Web Sockets
Go to full
specification
Opening handshake
GET /chat HTTP/1.1
Host: server.example.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
Origin: http://example.com
Sec-WebSocket-Protocol: chat, superchat
Sec-WebSocket-Version: 13
Client sends GET or CONNECT
request to Web Socket endpoint
Upgrade header indicates willing
to upgrade connection from
HTTP to WebSocket
Web Sockets
Go to full
specification
Opening handshake
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
Server responds with 101 status
code and connection upgrade
header
From now on Web Socket
protocol will be used instead of
HTTP
Web Sockets
Go to full
specification
API
var connection = new WebSocket('ws://html5rocks.websocket.org/echo');
Connection
Communication
// When the connection is open, send some data to the
server
connection.onopen = function () {
// Send the message 'Ping' to the server
connection.send('Ping');
};
// Log errors
connection.onerror = function (error) {
// Log messages from the server
console.log('WebSocket Error ' + error);
};
connection.onmessage = function (e) {
console.log('Server: ' + e.data);
};
Server-sent Events
Go to full
specification
Essentials
Support for auto reconnect
Support for event ids
Requires Content-Type: text/event-stream
Browser built-in long polling mechanism
Server-sent Events
Go to full
specification
Essentials
data: This is the first message.
data: This is the second message, it
data: has two lines.
data: This is the third message.
Response
event: add
data: 73857293
event: remove
data: 2153
event: add
data: 113411
Response with named Events
XHR Level 2
Go to full
specification
Essentials
What is XHR?
API for sending HTTP and HTTPS requests directly to Web Server
Supports plain text and structured response formats
Interaction without page refresh
Basement of AJAX
XHR Level 2
Go to full
specification
Interaction Model
AJAX
JavaScript
Document
Object
Model
XHR
Asynchronous
Web calls
DHTML
manipulations
XHR Level 2
Go to full
specification
Security
Strong security concerns
Same origin policy
Cross-origin resource
sharing policy
XHR Level 2
Go to full
specification
Security
Cross-origin communication scenarios
JSONP CORS
Blind
Proxies
Web
Messaging
Iframe
hacks
HTTP
forgery
XHR Level 2
Go to full
specification
Security
Way for a web server to allow its resources to be accessed by a web page
from a different domain
Requires server & client side support
Server side decides which origins are allowed
HTTP header based negotiation
What is cross-origin resource sharing?
XHR Level 2
Go to full
specification
Security
XHR Level 2
Go to full
specification
Security
Request
GET http://photos.contoso.com/albums HTTP/1.1
Origin: http://www.contoso.com
Origin header specifies that this is
CORS aware request.
Response
HTTP/1.1 200 OK
Access-Control-Allow-Origin: http://www.contoso.com
Server respond with special header
that allows browser to consume such
response
XHR Level 2
Go to full
specification
Security
Request
OPTIONS http://photos.contoso.com/albums HTTP/1.1
Origin: http://www.contoso.com
Access-Control-Request-Method: PUT
In case of non-safe methods web
browser should send preflight request
prior to sending actual request
Response
HTTP/1.1 200 OK
Access-Control-Allow-Origin: http://www.contoso.com
Access-Control-Allow-Methods: PUT
Server respond with special header
that allows browser to make actual
request
XHR Level 2
Go to full
specification
Features
Cross-origin
requests
Uploading
progress
events
Uploading
downloading
structured
data
XHR Level 2
Go to full
specification
Features
Structured data
Allows to get resources as structured object
Allows to post data as structured object
Controlled via responseType property
New response property to consume resource in structured format
XHR Level 2
Go to full
specification
Features
Structured formats (upload)
ArrayBuffer – generic fixed-length binary data buffer
FormData – object based representation of form fields
Blob – url accessible container for binary data
Document
DOMString – plain text response
XHR Level 2
Go to full
specification
Features
Structured formats (download)
arraybuffer – generic fixed-length binary data buffer
blob – url accessible container for binary data
document
text – plain text response
json – json string converted into object
XHR Level 2
Go to full
specification
Features
Structured data var xhr = new XMLHttpRequest();
xhr.open('GET', '/path/to/image.png', true);
xhr.responseType = 'arraybuffer';
xhr.onload = function(e) {
var uInt8Array = new Uint8Array(this.response);
var byte3 = uInt8Array[4]; // byte at offset 4 ...
};
xhr.send();
GET example
Geolocation
Essentials
Go to full
specification
Mechanism for determining user geographic coordinates
Available on desktop and mobile devices
Uses GPS, A-GPS, Wi-Fi hotspots or IP address range to determine current
coordinates
Easy to use JavaScript API
Strong security concerns
What is Geolocation?
Geolocation
API
Go to full
specification
Main object – navigator.geolocation
getCurrentPosition – gets current position & speed (if possible)
watchPosition – track position changes
clearWatch – stop tracking position changes
Device Orientation
Essentials
Mechanism for determining Euler`s angles (rotation around X,Y, Z)
Supported on broad variety of mobile devices
What is device orientation?
The deviceorientation event with orientation data passed along
The devicemotion event with orientation and acceleration data
passed along
Application Cache
Essentials
Go to full
specification
Software storage feature which provides the ability to access a web
application even without a network
Controlled by a plain text file called a cache manifest
Can be managed by JavaScript API
What is Web Application Cache?
Application Cache
Manifest file
Go to full
specification
Contains a list of resources to be stored for use when there is no network
connectivity
Defines conditions for caching
Consist of sections
CACHE – a list of explicit urls to request and store
FALLBACK - What to do when an offline user attempts to
access an uncached file
NETWORK – Which resources are available only when online
Application Cache
Manifest file
Go to full
specification
<!DOCTYPE HTML>
<html manifest="/cache.appcache">
<body> … </body>
</html>
Page markup
CACHE MANIFEST
# This is a comment
CACHE:
/css/screen.css
/css/offline.css
/js/screen.js
/img/logo.png
http://example.com/css/styles.css
FALLBACK:
/ /offline.html
NETWORK:
*
Manifest file
CSS 3
Graphics Features
Transparency
color specification with alpha, opacity property
Round corners
border-radius
Shadows
box-shadow, text-shadow
Background gradients
linear, radial
Typography
Web Open Font Format (WOFF) fonts
2D & 3D Transforms
Display-time transformations of any HTML content
transforms do not affect layout
2D Transforms
translate, scale, rotate, skew
3D Transforms
translate, scale, rotate, skew in X, Y & Z
perspective
Animations & Transitions
Transitions
smooth animation of CSS properties from old to new value
can be used with CSS pseudo-classes such as :hover
Animations
keyframe-based definition of a set of CSS property changes
allows richer animations than CSS Transitions
event model allows complex use in combination with script
Animations & Transitions
#id_of_element {
-webkit-transition: all 1s ease-in-out;
-moz-transition: all 1s ease-in-out;
-o-transition: all 1s ease-in-out;
-ms-transition: all 1s ease-in-out;
transition: all 1s ease-in-out;
}
Transition
@keyframes resize {
0% { padding: 0; }
50% {
padding: 0 20px;
background-color:rgba(255,0,0,0.2);
}
100% {
padding: 0 100px;
background-color:rgba(255,0,0,0.9);
}
}
#box {
animation-name: resize;
animation-duration: 1s;
animation-iteration-count: 4;
animation-direction: alternate;
animation-timing-function: ease-in-out; }
Animation
Markup
New Tags
Semantic Input types Multimedia Other
New Tags
<article>
Specifies independent, self-contained content, could be a news-article,
blog post, forum post, or other articles which can be distributed
independently from the rest of the site.
<aside>
For content aside from the content it is placed in. The aside content
should be related to the surrounding content
<bdi>
For text that should not be bound to the text-direction of its parent
elements
<command> A button, or a radiobutton, or a checkbox
<details> For describing details about a document, or parts of a document
<summary> A caption, or summary, inside the details element
<figure> For grouping a section of stand-alone content, could be a video
<figcaption> The caption of the figure section
<footer>
For a footer of a document or section, could include the name of the
author, the date of the document, contact information, or copyright
information
<header> For an introduction of a document or section, could include navigation
<hgroup>
For a section of headings, using <h1> to <h6>, where the largest is
the main heading of the section, and the others are sub-headings
<mark> For text that should be highlighted
<meter>
For a measurement, used only if the maximum and minimum values
are known
<nav> For a section of navigation
<progress> The state of a work in progress
<ruby> For ruby annotation (Chinese notes or characters)
<rt> For explanation of the ruby annotation
<rp> What to show browsers that do not support the ruby element
<section>
For a section in a document. Such as chapters, headers, footers, or
any other sections of the document
<time> For defining a time or a date, or both
<wbr> Word break. For defining a line-break opportunity.
Semantic Markup
div=”header”
div=”nav”
div=”footer”
div=”article” div=”sidebar”
div
HTML4
XHTML4
Semantic Markup
<header>
<nav>
<footer>
<article> <aside>
<section>
HTML5
XHTML5
Semantic Markup
Input Types
13 new input types
Built-in client-side validation
Poor support in desktop browsers
See browser compatibility
information
Input Types
search tel url email datetime
date month week time
datetime-
local
number range color
HTML5
Feature detection
Never use navigator.userAgent browser detection hack
Never use conditional comment in Internet Explorer
Use feature detecting instead of browser detection when possible
Consider graceful fallback
Use Modernizr
Feature detection
Modernizr
Modernizr is a small JavaScript Library that detects the availability
of native implementations for next-generation web technologies
What is Modernizr?
Why Modernizr?
Easy to use
Powerfull feature detection library
Feature detection
Modernizr
Modernizr does its “magic” by creating an element, setting a specific
style instruction on that element and then immediately retrieving it
How it works?
Feature detection results available to developer via JavaScript
Modernizr object and classes applied to HTML DOM element
Feature detection
Modernizr
How it looks like?
/* In your CSS: */
.no-audio #music {
display: none; /* Don't show Audio options */
}
.audio #music button {
/* Style the Play and Pause buttons nicely */
}
<!-- In your HTML: -->
<div id="music">
<audio>
<source src="audio.ogg" />
<source src="audio.mp3" />
</audio>
<button id="play">Play</button>
<button id="pause">Pause</button>
</div>
Links
Useful HTML5 content
http://www.html5rocks.com
HTML5 news, demos, presentations
http://www.html5doctor.com
Lot of HTML5 tutorials, articles
http://ie.microsoft.com/testdrive/Graphics/h
ands-on-css3/
HTML5 Hands-On
THE END

Contenu connexe

Tendances

Open Source World : Using Web Technologies to build native iPhone and Android...
Open Source World : Using Web Technologies to build native iPhone and Android...Open Source World : Using Web Technologies to build native iPhone and Android...
Open Source World : Using Web Technologies to build native iPhone and Android...Jeff Haynie
 
Sg conference multiplatform_apps_adam_stanley
Sg conference multiplatform_apps_adam_stanleySg conference multiplatform_apps_adam_stanley
Sg conference multiplatform_apps_adam_stanleyn_adam_stanley
 
Sencha touchonbb10 bootcamp
Sencha touchonbb10 bootcampSencha touchonbb10 bootcamp
Sencha touchonbb10 bootcampn_adam_stanley
 
Using Cool New Frameworks in (Mobile) Domino Apps
Using Cool New Frameworks in (Mobile) Domino AppsUsing Cool New Frameworks in (Mobile) Domino Apps
Using Cool New Frameworks in (Mobile) Domino AppsTeamstudio
 
Development Workshop on ET1, Android and Motorola RhoElements
Development Workshop on ET1, Android and Motorola RhoElementsDevelopment Workshop on ET1, Android and Motorola RhoElements
Development Workshop on ET1, Android and Motorola RhoElementsRomin Irani
 
Anatomy of an HTML 5 mobile web app
Anatomy of an HTML 5 mobile web app Anatomy of an HTML 5 mobile web app
Anatomy of an HTML 5 mobile web app Ivano Malavolta
 
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
JavaOne - 10 Tips for Java EE 7 with PrimeFacesJavaOne - 10 Tips for Java EE 7 with PrimeFaces
JavaOne - 10 Tips for Java EE 7 with PrimeFacesMert Çalışkan
 
A Work Day Of A Web Developer
A Work Day Of A Web DeveloperA Work Day Of A Web Developer
A Work Day Of A Web DeveloperEdureka!
 
What's Coming in Java EE 8
What's Coming in Java EE 8What's Coming in Java EE 8
What's Coming in Java EE 8PT.JUG
 
S60 3rd FP2 Widgets
S60 3rd FP2 WidgetsS60 3rd FP2 Widgets
S60 3rd FP2 Widgetsromek
 
Lightning Web Component in Salesforce
Lightning Web Component in SalesforceLightning Web Component in Salesforce
Lightning Web Component in SalesforceJitendra Zaa
 
Responsive Websites and Grid-Based Layouts by Gabriel Walt
Responsive Websites and Grid-Based Layouts by Gabriel Walt Responsive Websites and Grid-Based Layouts by Gabriel Walt
Responsive Websites and Grid-Based Layouts by Gabriel Walt AEM HUB
 
A Gentle introduction to Web Development & Django
A Gentle introduction to Web Development & DjangoA Gentle introduction to Web Development & Django
A Gentle introduction to Web Development & DjangoPRASANNAVENK
 
MicroProfile for MicroServices
MicroProfile for MicroServicesMicroProfile for MicroServices
MicroProfile for MicroServicesMert Çalışkan
 

Tendances (20)

Agile toolkit present 2012
Agile toolkit present 2012Agile toolkit present 2012
Agile toolkit present 2012
 
Agile toolkit present 2012
Agile toolkit present 2012Agile toolkit present 2012
Agile toolkit present 2012
 
Open Source World : Using Web Technologies to build native iPhone and Android...
Open Source World : Using Web Technologies to build native iPhone and Android...Open Source World : Using Web Technologies to build native iPhone and Android...
Open Source World : Using Web Technologies to build native iPhone and Android...
 
Sg conference multiplatform_apps_adam_stanley
Sg conference multiplatform_apps_adam_stanleySg conference multiplatform_apps_adam_stanley
Sg conference multiplatform_apps_adam_stanley
 
Sencha touchonbb10 bootcamp
Sencha touchonbb10 bootcampSencha touchonbb10 bootcamp
Sencha touchonbb10 bootcamp
 
Using Cool New Frameworks in (Mobile) Domino Apps
Using Cool New Frameworks in (Mobile) Domino AppsUsing Cool New Frameworks in (Mobile) Domino Apps
Using Cool New Frameworks in (Mobile) Domino Apps
 
Edge of the Web
Edge of the WebEdge of the Web
Edge of the Web
 
Development Workshop on ET1, Android and Motorola RhoElements
Development Workshop on ET1, Android and Motorola RhoElementsDevelopment Workshop on ET1, Android and Motorola RhoElements
Development Workshop on ET1, Android and Motorola RhoElements
 
Anatomy of an HTML 5 mobile web app
Anatomy of an HTML 5 mobile web app Anatomy of an HTML 5 mobile web app
Anatomy of an HTML 5 mobile web app
 
Frameworks in java
Frameworks in javaFrameworks in java
Frameworks in java
 
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
JavaOne - 10 Tips for Java EE 7 with PrimeFacesJavaOne - 10 Tips for Java EE 7 with PrimeFaces
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
 
A Work Day Of A Web Developer
A Work Day Of A Web DeveloperA Work Day Of A Web Developer
A Work Day Of A Web Developer
 
What's Coming in Java EE 8
What's Coming in Java EE 8What's Coming in Java EE 8
What's Coming in Java EE 8
 
S60 3rd FP2 Widgets
S60 3rd FP2 WidgetsS60 3rd FP2 Widgets
S60 3rd FP2 Widgets
 
Lightning Web Component in Salesforce
Lightning Web Component in SalesforceLightning Web Component in Salesforce
Lightning Web Component in Salesforce
 
JavaCro'14 - Vaadin web application integration for Enterprise systems – Pete...
JavaCro'14 - Vaadin web application integration for Enterprise systems – Pete...JavaCro'14 - Vaadin web application integration for Enterprise systems – Pete...
JavaCro'14 - Vaadin web application integration for Enterprise systems – Pete...
 
JavaCro'15 - Java EE 8 - An instant snapshot - David Delabassee
JavaCro'15 - Java EE 8 - An instant snapshot - David DelabasseeJavaCro'15 - Java EE 8 - An instant snapshot - David Delabassee
JavaCro'15 - Java EE 8 - An instant snapshot - David Delabassee
 
Responsive Websites and Grid-Based Layouts by Gabriel Walt
Responsive Websites and Grid-Based Layouts by Gabriel Walt Responsive Websites and Grid-Based Layouts by Gabriel Walt
Responsive Websites and Grid-Based Layouts by Gabriel Walt
 
A Gentle introduction to Web Development & Django
A Gentle introduction to Web Development & DjangoA Gentle introduction to Web Development & Django
A Gentle introduction to Web Development & Django
 
MicroProfile for MicroServices
MicroProfile for MicroServicesMicroProfile for MicroServices
MicroProfile for MicroServices
 

En vedette

En vedette (20)

Company Brochure
Company BrochureCompany Brochure
Company Brochure
 
Doc1
Doc1Doc1
Doc1
 
Turbo-Charge RightNow with Cloud Integration
Turbo-Charge RightNow with Cloud IntegrationTurbo-Charge RightNow with Cloud Integration
Turbo-Charge RightNow with Cloud Integration
 
PROGRAM LINIER
PROGRAM LINIERPROGRAM LINIER
PROGRAM LINIER
 
Creativebrief
CreativebriefCreativebrief
Creativebrief
 
Leopardpublishing 2012
Leopardpublishing 2012Leopardpublishing 2012
Leopardpublishing 2012
 
Assignment 13
Assignment 13Assignment 13
Assignment 13
 
Art presentation
Art presentationArt presentation
Art presentation
 
Formúlario servicios 1
Formúlario servicios 1Formúlario servicios 1
Formúlario servicios 1
 
Business english-teleconference-functions
Business english-teleconference-functionsBusiness english-teleconference-functions
Business english-teleconference-functions
 
CDPL content examples
CDPL content examplesCDPL content examples
CDPL content examples
 
план урока
план урокаплан урока
план урока
 
Generic online events
Generic online eventsGeneric online events
Generic online events
 
Shashank ppt
Shashank pptShashank ppt
Shashank ppt
 
Wclf infomation for participants
Wclf infomation for participantsWclf infomation for participants
Wclf infomation for participants
 
Discover south africawww. Tripmart.com
Discover south africawww. Tripmart.comDiscover south africawww. Tripmart.com
Discover south africawww. Tripmart.com
 
Cutting Out the Middle Man: Crowdfunding and Kickstarter
Cutting Out the Middle Man: Crowdfunding and KickstarterCutting Out the Middle Man: Crowdfunding and Kickstarter
Cutting Out the Middle Man: Crowdfunding and Kickstarter
 
Secuencia Convivencia
Secuencia ConvivenciaSecuencia Convivencia
Secuencia Convivencia
 
Raid technologies
Raid technologiesRaid technologies
Raid technologies
 
Learning organisations and design thinking
Learning organisations and design thinkingLearning organisations and design thinking
Learning organisations and design thinking
 

Similaire à HTML5 Comprehensive Guide

HTML5 introduction for beginners
HTML5 introduction for beginnersHTML5 introduction for beginners
HTML5 introduction for beginnersVineeth N Krishnan
 
Workshop HTML5+PhoneGap by Ivano Malavolta
Workshop HTML5+PhoneGap by Ivano Malavolta Workshop HTML5+PhoneGap by Ivano Malavolta
Workshop HTML5+PhoneGap by Ivano Malavolta Commit University
 
Thadomal IEEE-HTML5-Workshop
Thadomal IEEE-HTML5-WorkshopThadomal IEEE-HTML5-Workshop
Thadomal IEEE-HTML5-WorkshopRomin Irani
 
HTML5: the new frontier of the web
HTML5: the new frontier of the webHTML5: the new frontier of the web
HTML5: the new frontier of the webIvano Malavolta
 
Html5 workshop part 1
Html5 workshop part 1Html5 workshop part 1
Html5 workshop part 1NAILBITER
 
HTML5 Intoduction for Web Developers
HTML5 Intoduction for Web DevelopersHTML5 Intoduction for Web Developers
HTML5 Intoduction for Web DevelopersSascha Corti
 
Planning for Windows 10 and Internet Explorer 11
Planning for Windows 10 and Internet Explorer 11 Planning for Windows 10 and Internet Explorer 11
Planning for Windows 10 and Internet Explorer 11 Flexera
 
WordCamp Thessaloniki2011 The NextWeb
WordCamp Thessaloniki2011 The NextWebWordCamp Thessaloniki2011 The NextWeb
WordCamp Thessaloniki2011 The NextWebGeorge Kanellopoulos
 
HTML5 Webinar - Mind Storm Software
HTML5 Webinar - Mind Storm SoftwareHTML5 Webinar - Mind Storm Software
HTML5 Webinar - Mind Storm SoftwareRomin Irani
 
soft-shake.ch - Introduction to HTML5
soft-shake.ch - Introduction to HTML5soft-shake.ch - Introduction to HTML5
soft-shake.ch - Introduction to HTML5soft-shake.ch
 
Web Development Presentation
Web Development PresentationWeb Development Presentation
Web Development PresentationTurnToTech
 
Netbeans65 Osum Slides
Netbeans65 Osum SlidesNetbeans65 Osum Slides
Netbeans65 Osum SlidesAbhishek Gupta
 
Angular jS Introduction by Google
Angular jS Introduction by GoogleAngular jS Introduction by Google
Angular jS Introduction by GoogleASG
 
Mobile Web Applications using HTML5 [IndicThreads Mobile Application Develop...
Mobile Web Applications using HTML5  [IndicThreads Mobile Application Develop...Mobile Web Applications using HTML5  [IndicThreads Mobile Application Develop...
Mobile Web Applications using HTML5 [IndicThreads Mobile Application Develop...IndicThreads
 
A Microsoft primer for PHP devs
A Microsoft primer for PHP devsA Microsoft primer for PHP devs
A Microsoft primer for PHP devsguest0a62e8
 

Similaire à HTML5 Comprehensive Guide (20)

HTML5 introduction for beginners
HTML5 introduction for beginnersHTML5 introduction for beginners
HTML5 introduction for beginners
 
Workshop HTML5+PhoneGap by Ivano Malavolta
Workshop HTML5+PhoneGap by Ivano Malavolta Workshop HTML5+PhoneGap by Ivano Malavolta
Workshop HTML5+PhoneGap by Ivano Malavolta
 
Thadomal IEEE-HTML5-Workshop
Thadomal IEEE-HTML5-WorkshopThadomal IEEE-HTML5-Workshop
Thadomal IEEE-HTML5-Workshop
 
HTML5: the new frontier of the web
HTML5: the new frontier of the webHTML5: the new frontier of the web
HTML5: the new frontier of the web
 
Html5 workshop part 1
Html5 workshop part 1Html5 workshop part 1
Html5 workshop part 1
 
Word camp nextweb
Word camp nextwebWord camp nextweb
Word camp nextweb
 
Word camp nextweb
Word camp nextwebWord camp nextweb
Word camp nextweb
 
Html5 Basics
Html5 BasicsHtml5 Basics
Html5 Basics
 
HTML5 Intoduction for Web Developers
HTML5 Intoduction for Web DevelopersHTML5 Intoduction for Web Developers
HTML5 Intoduction for Web Developers
 
Planning for Windows 10 and Internet Explorer 11
Planning for Windows 10 and Internet Explorer 11 Planning for Windows 10 and Internet Explorer 11
Planning for Windows 10 and Internet Explorer 11
 
WordCamp Thessaloniki2011 The NextWeb
WordCamp Thessaloniki2011 The NextWebWordCamp Thessaloniki2011 The NextWeb
WordCamp Thessaloniki2011 The NextWeb
 
5. HTML5
5. HTML55. HTML5
5. HTML5
 
HTML5 Webinar - Mind Storm Software
HTML5 Webinar - Mind Storm SoftwareHTML5 Webinar - Mind Storm Software
HTML5 Webinar - Mind Storm Software
 
soft-shake.ch - Introduction to HTML5
soft-shake.ch - Introduction to HTML5soft-shake.ch - Introduction to HTML5
soft-shake.ch - Introduction to HTML5
 
Web Development Presentation
Web Development PresentationWeb Development Presentation
Web Development Presentation
 
Html5
Html5Html5
Html5
 
Netbeans65 Osum Slides
Netbeans65 Osum SlidesNetbeans65 Osum Slides
Netbeans65 Osum Slides
 
Angular jS Introduction by Google
Angular jS Introduction by GoogleAngular jS Introduction by Google
Angular jS Introduction by Google
 
Mobile Web Applications using HTML5 [IndicThreads Mobile Application Develop...
Mobile Web Applications using HTML5  [IndicThreads Mobile Application Develop...Mobile Web Applications using HTML5  [IndicThreads Mobile Application Develop...
Mobile Web Applications using HTML5 [IndicThreads Mobile Application Develop...
 
A Microsoft primer for PHP devs
A Microsoft primer for PHP devsA Microsoft primer for PHP devs
A Microsoft primer for PHP devs
 

Plus de Alexei Skachykhin

Plus de Alexei Skachykhin (6)

CSS Architecture: Writing Maintainable CSS
CSS Architecture: Writing Maintainable CSSCSS Architecture: Writing Maintainable CSS
CSS Architecture: Writing Maintainable CSS
 
Representational State Transfer
Representational State TransferRepresentational State Transfer
Representational State Transfer
 
Web Real-time Communications
Web Real-time CommunicationsWeb Real-time Communications
Web Real-time Communications
 
Code Contracts
Code ContractsCode Contracts
Code Contracts
 
JavaScript as Development Platform
JavaScript as Development PlatformJavaScript as Development Platform
JavaScript as Development Platform
 
Windows 8
Windows 8Windows 8
Windows 8
 

Dernier

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 

Dernier (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 

HTML5 Comprehensive Guide

  • 2. What is HTML5? “Specification that defines the 5th major revision of the core language of the World Wide Web: HTML.” World Wide Web Consortium
  • 6. Who’s in charge? Ian Hickson Editor of HTML5 specification
  • 7. Standardisation Editor`s Draft First Public Working Draft Last Call Candidate Recommendation Recommendation
  • 8. State of HTML5 “So we opened a mailing list called the WHATWG to continue work on Web Forms 2.0 in public, and later that year started a new draft called Web Applications 1.0 into which we put many features aimed at writing Web apps, including a new version of HTML that we jokingly called HTML5…” 2004 Ian Hickson
  • 10. State of HTML5 Early expectations 2012 – W3C Candidate Recommendation W3C Recommendation 2020?
  • 11. State of HTML5 Reality 2012 – W3C Candidate Recommendation W3C Recommendation 2014
  • 12. State of HTML5 Old browsers (Q1 2013) More on: www.html5test.com ~ 33% IE 6-8 FF 3-3.6 OP 9x
  • 13. State of HTML5 Mobile Platforms Various degree of support in mobile operating systems. iOS Android Window Phone BlackBerry
  • 14. State of HTML5 jQuery 2.0 Drops support of legacy browsers
  • 15. State of HTML5 “JQuery 2.0 now has more patches and shims for Chrome, Safari, and Firefox than for Internet Explorer.” Dave Methvin President, jQuery Foundation
  • 17. State of HTML5 Already moved to HTML5
  • 18. State of HTML5 “When I`m introspective about last few years I think the biggest mistake we made as a company was betting too much on HTML5 as opposed to native… because it just wasn`t there. … We burned two years. It`s really painful.” Mark Zuckerberg SEO of Facebook, September 2012
  • 19. Goals of HTML5 Native Multimedia Programmatic Context Enhanced Web Semantics “Plug-in free” Development
  • 20. Goals of HTML5 Adobe Flash What is wrong with Adobe Flash? Lot of security vulnerabilities Low performance on older machines Disallowed on mobile devices Requires user to install separate plug-in
  • 21. Goals of HTML5 Silverlight What is wrong with Silverlight? Tied to Windows Requires user to install separate plug-in Historical dislike of Microsoft
  • 22. State of HTML5 Be pragmatic Stability Use what works today Granularity Use what you need Rationality Web Standards not always fit
  • 23. State of HTML5 “And it`s not that HTML5 is bad. I`m actually, on long-term, really excited about it. One of the things that`s interesting is we actually have more people on a daily basis using mobile Web Facebook than we have using our iOS and Android apps combined. So mobile Web is a big thing for us.” Mark Zuckerberg SEO of Facebook, September 2012
  • 24. HTML5 How to take advantage of HTML5? You already, DO! How to enable HTML5 standards mode in browsers? <!DOCTYPE html> Place this on top of your document. No DTD!
  • 25. HTML5 Tools Visual Studio 2012 with Web Essentials. For .NET Developers Expression Web For non .NET Developers Adobe Dreamweaver Aptana Studio JetBrains WebStorm
  • 26. HTML5 Storage API`s Web SQL IndexedDBWeb Storage Local Storage Session Storage
  • 27. Web Storage Local Storage Persistent store for up to 5 MiB of data on users local machine (10 MiB for IE) Essential details Never transferred to server side (no- cookies) Accessible from JavaScript Store for Key-Value pairs of strings Important notes Objects should be stringifyed prior to saving to localStorage It is allowed for browser to clear localStorage without user permission Go to full specification
  • 28. Web Storage Session Storage Non-Persistent store for up to 5 MiB of data on users local machine (10 MiB for IE) Essential details Go to full specification Data accessible only during current session (browser tabs) Shares API with localStorage
  • 29. Web StorageLocal Storage & Session Storage setItem(key, value) - to set something to the browsers storage API Go to full specification getItem(key) – to get value from storage removeItem(key) – to remove item from storage clear() – to clear storage
  • 30. Web SQLEssentials What`s is Web SQL? Go to full specification Web SQL Database is a web page API for storing data in databases that can be queried using a variant of SQL Full power of relational database on client side Support for transactions Specification based on SQLite Synchronous and asynchronous API
  • 31. Web SQL What`s the state of Web SQL? Go to full specification Deprecated! Working Group does not intend to maintain it further. What`s wrong with Web SQL? All interested implementers have used the same SQL backend (SQLite), but W3C need multiple independent implementations to proceed along a standardization path. Essentials
  • 32. Web SQL Go to full specification openDatabase – opens or creates database API transaction – creates transaction executeSql – used for executing SQL read and write statements
  • 33. IndexedDBEssentials What`s is IndexedDB? Go to full specification IndexedDB is an API for client-side storage of significant amounts of structured data It`s an object store, but it`s not a relational database. Support for transactions Support for indexes Synchronous and asynchronous API
  • 34. IndexedDBEssentials Specific terms of IndexedDB Go to full specification Database comprises one or more object stores which hold the data stored in the database Object Store is the primary storage mechanism for storing data in a database Transaction is used to interact with the data in a database Request represents one read or write operation
  • 36. Native Multimedia Essentials Abstract MediaElement Audio & Video has common API First class citizen of DOM
  • 37. Application Programming Interface Native Multimedia Programmatic Context Go to full specification Events Network- related Buffering level Playback control and feature detection
  • 38. Native Multimedia Events Go to full specification Loadstart Progress Suspend Abort Error Emptied Stalled Network-related loadedmetadata loadeddata waiting playing canplay canplaythrough Buffering level
  • 39. Native Multimedia JavaScript & CSS Go to full specification First-class DOM citizen and can be styles with CSS3 Exposes properties and functions to JavaScript Properties Functions playbackRate volume muted networkState readyState currentTime play pause load
  • 40. Native Multimedia Format Support Go to full specification “…regarding codecs for <video> and <audio> in HTML5, I have reluctantly come to the conclusion that there is no suitable codec that all vendors are willing to implement and ship.” Ian Hickson
  • 41. Audio Essentials Built in tag <audio> for embedding audio player Natively support – require no plug-ins Out of the box user interface API for controlling audio playback Go to full specification
  • 42. Audio Essentials Go to full specification Attributes of <audio> tag Src - media content source Preload - attribute is intended to provide a hint to the user agent about what the author thinks will lead to the best user experience. None – do not preload Metadata – preload metadata only Auto – let browser decide Controls – specifies whether built-in controls visible or not Loop - indicates that the media element should to seek back to the start Crossorigin - indicates that audio file is being served from different origin
  • 43. Audio Essentials Go to full specification Tools of the Devil Loop - indicates that the media element should to seek back to the start Autoplay - indicates that the media element should automatically start playback once its fully loaded
  • 44. Audio Look & Feel Go to full specification How does it looks like? What the markup is? <audio controls="controls"> <source src="song.ogg" type="audio/ogg" /> <source src="song.mp3" type="audio/mpeg" /> Your browser does not support the audio element. </audio>
  • 45. Audio Programmatic Context Go to full specification play - to play audio API pause – to pause audio canPlayType(type) – determines whether type supported by user agent buffered – attribute that specifies the start and end time of the buffered part of the file
  • 46. Audio Format Support Go to full specification MP3 WebM OGG AAC
  • 47. Video Essentials Built in tag <video> for embedding video player Natively support – require no plug-ins Out of the box user interface API for controlling video playback Go to full specification
  • 48. Video Video formats Go to full specification MPEG4 + WebM + OGG +
  • 49. Video Essentials Go to full specification Attributes of <video> tag Src - media content source Preload - attribute is intended to provide a hint to the user agent about what the author thinks will lead to the best user experience. None – do not preload Metadata – preload metadata only Auto – let browser decide Controls – specifies whether standard controls visible or not Poster – image to show while no video data is available
  • 50. Video Look & Feel Go to full specification How does it looks like? What the markup is? <video width="320" height="240" controls="controls"> <source src="movie.mp4" type="video/mp4" /> <source src="movie.ogg" type="video/ogg" /> Your browser does not support the video tag. </video>
  • 51. Video Issues Go to full specification Fullscreen playing Live Streaming Patchy browser support
  • 52. Canvas Essentials Go to full specification HTML5 element that allows for dynamic, scriptable rendering of 2D shapes and bitmaps Immediate mode rendering Rich API: 45 methods, 21 attributes Future plans for 3D rendering
  • 53. Canvas Go to full specification API Application Programming Interface State Transformations Compositing Color & Styles Line caps/joins Shadows Rectangles Path API Text Pixel manipulation Focus management Drawing images
  • 54. Canvas History Go to full specification Developed as platform for OSX Dashboard Widgets in 2004
  • 55. Canvas Use cases Go to full specification Data visualization
  • 56. Canvas Use cases Go to full specification Animated graphics
  • 57. Canvas Use cases Go to full specification Web Applications
  • 58. Canvas Use cases Go to full specification Games
  • 59. Canvas Markup Go to full specification What the markup is? <canvas width=‘800’ height=‘600’> Your browser doesn`t support canvas. </canvas>
  • 60. Canvas Coordinate System Go to full specification (0, 0) X Y
  • 61. Canvas Rendering Context Go to full specification 2D Rendering Context Everything is drawn onto 2D rendering context that is tied to Canvas instance
  • 62. Canvas Rendering Context Go to full specification Context instance can be preserved and passed around the app How to get context? var canvas = document.getElementById(‘canvas’) var context = canvas.getContext(‘2d’)
  • 63. Canvas Drawing Model Go to full specification How to change color? var canvas = document.getElementById(‘canvas’) var context = canvas.getContext(‘2d’) context.fillStyle = ‘black’; context.strokeStyle = ‘white’;
  • 64. Canvas Drawing Model Go to full specification fillRect - draws a rectangle using current fill style Simple shapes strokeRect – draws the outline of a rectangle using the current stroke style clearRect – clears all pixels within the given rectangle
  • 65. Canvas Drawing Model Go to full specification Complex shapes A new patch should be created for each complex shape Paths are a list of subpath Subpaths are one or more points connected by straight or curved lines Rendering context has reference to current active path
  • 66. Canvas Drawing Model Go to full specification Complex shapes beginPath – resets the current path closePath – closes the current subpath and starts a new one fill – fills the subpaths with the current fill style stroke – outlines the subpaths with the current stroke style
  • 67. Canvas Drawing Model Go to full specification Complex shapes lineTo – draws a straight line from the previous point rect – adds a new closed rectangular subpath arc – adds a subpath along the circumference of the described circle, withing the angles defined arcTo – adds a subpath connecting two points by an arc of the defined radius
  • 68. Canvas Drawing Model Go to full specification Transformations Affects shapes and paths drawn after the transformation Shorthand methods for translation, scaling, rotation Transformation matrices are allowed
  • 69. Canvas Drawing Model Go to full specification Transformations translate – moves coordinate system by specified offset rotate – rotates coordinate system by specified angle scale – scales coordinate system by specified factor transform – multiplies current transformation matrix with specified one setTransform – sets transformation matrix directly
  • 70. Canvas Drawing Model Go to full specification ctx.shadowOffsetX = 10; ctx.shadowOffsetY = 10; ctx.shadowBlur = 10; ctx.shadowColor = "rgba(0, 0, 0, 1)"; ctx.fillText(“Winning!”, 10, 25); // All future operations will also have a shadow ctx.strokeRect(0, 0, 115, 40); All Canvas attributes are global – they effect all operations drawn next.
  • 71. Canvas Drawing Model Go to full specification The current values of the following attributes: strokeStyle, fillStyle, globalAlpha, lineWidth, lineCap, lineJoin, miterLimit, shadowOffsetX, shadowOffsetY, shadowBlur, shadowColor, globalCompositeOperation, font, textAlign, textBaseline. You can save and restore: The current transformation matrix. The current clipping region.
  • 72. Canvas State Management Go to full specification ctx.save(); ctx.shadowOffsetX = 10; ctx.shadowOffsetY = 10; ctx.shadowBlur = 10; ctx.shadowColor = "rgba(0, 0, 0, 1)"; ctx.fillText(“Winning!”, 10, 25); ctx.restore(); // All future operations will NOT have a shadow ctx.strokeRect(0, 0, 115, 40); Use save() and restore() to scope the attribute
  • 73. Canvas Composition Go to full specification Compositing it the control of transparency and layering of objects Controlled by globalAlpha and globalCompositeOperation attributes
  • 75. Canvas Drawing Model Go to full specification Firefox, Opera and Internet Explorer follow the drawing model as described in the spec. Safari and Chrome have a slightly different drawing model behavior. DO: Check if you’re composition is impacted by this interoperability issue.
  • 76. Canvas Performance Go to full specification Not all operations were made equal. Some are more expensive than others Shadows, clipping and composition operations are more expensive as they require an additional intermediate. DON’T: Create thousands of small objects with clipping, shadows or compositions effects.
  • 77. Canvas Security Model Go to full specification Canvas allows reading and writing pixels to the screen You can also save the Canvas to a file via toDataURL() Canvas PNG File
  • 78. Canvas also allows drawing cross-domain images/videos However, it has built-in security protection against third-parties saving cross-domain pixels Canvas Security Model Go to full specification Canvas PNG File
  • 79. Canvas Security Model Go to full specification Canvas has a concept of origin-clean flag. origin-clean is set false if a cross-domain IMG or VIDEO is used. A SECURITY_ERR exception is raised, if one tries to save the Canvas pixels if the Canvas origin-clean is false: toDataURL() getImageData()
  • 80. Animation Frame API Essentials Go to full specification API for getting precise animation updates User Agent schedules updates in sync with internal redraw routines Automatic management of update time and low-power mode
  • 81. Animation Frame API Go to full specification requestAnimationFrame – requests repaint callback to be scheduled API cancelAnimationFrame – cancels repaint callback request
  • 83. HTML Media Capture Essentials Native media capture mechanism Extends file input Allows to capture audio, video and photo
  • 84. HTML Media Capture Markup What the markup is? <input type="file" accept="image/*" capture="camera" /> <input type="file" accept="audio/*" capture="microphone" /> <input type="file" accept="video/*" capture="camcorder" /> Media format controlled by accept attribute Media type controlled by capture attribute
  • 85. User Media API Essentials API that allows to capture media streams Designed to interoperate with related specs Allows to capture audio, video and photo
  • 86. User Media API Essentials High level abstraction for streaming data Can be passed around to different APIs Contains audio and video tracks Media Stream Media Stream Track High level abstraction for media stream source
  • 88. User Media API Programmatic Context Go to full specification getUserMedia - to start capturing media stream API
  • 90. JavaScript DSP Essentials Byte-level manipulations with encoded audio data Getting audio data via XMLHttpRequest or File API Requires knowledge of DSP and audio formats encoding Extension: Firefox allows access to PCM data
  • 91. Web Audio API Why? <audio> hides the steps of loading, decoding and playing No standard way to access raw PCM data No fine-grained timing No concept of position and direction of sources and listeners Hard to analyze and visualize data on the fly
  • 92. Web Audio API Essentials High-level API for processing and synthesizing audio Gives fine grained control over audio processing and playback
  • 93. Web Audio API Real-time processing and synthesizing audio Capabilities An audio pipeline and routing system for effects and filters
  • 94. Web Audio API Access to raw PCM data Capabilities
  • 95. Web Audio API Precise scheduling of audio playback Capabilities
  • 96. Web Audio API Audio Context Abstract representation of audio signal graph and connections between AudioNodes
  • 97. Web Audio API Audio Context API destination – audio node that represents actual hardware sampleRate – the sample rate at which Audio Context handles audio currentTime – time in seconds tied to hardware clock listener – an audio listener that is used for 3D spatialization
  • 98. Web Audio API Audio Node Build block of audio graph Audio node represents Source Destination Intermediate processing module Set of predefined Audio Nodes as well as ScriptProcessorNode
  • 99. Web Audio API Audio Node AudioDestinationNode AudioBufferSourceNode MediaElementAudioSourceNode MediaStreamAudioSourceNode MediaStreamAudioDestinationNode ScriptProcessorNode Audio Effect Nodes
  • 100. Web Audio API Audio Buffer Represents in-memory audio asset Contains IEEE 32-bit linear PCM with a nominal range of -1 -> +1 Contains one or more channels Typically expected that length of PCM data would be less than a minute Long audio tracks can be served via MediaElementAudioSourceNode
  • 102. HTML5 Image-based 3D Set of prerendered images High degree of browser support Terrific amount of data to load No client side customizations
  • 103. Image-based 3D Image-based 3D Fast image switches may cause flickering Rendering to Canvas may give significant performance boost
  • 104. HTML5 Software Rendering Rendering and computations are made on CPU Manual manipulations with Pixel and Vertex data Canvas as rasterization surface
  • 105. Software Rendering Performance Software rendering is inherently slow Good enough for simple scenes Mobile devices are still a concern
  • 106. HTML5 CSS3 Transforms Display-time transformations of any HTML content transforms do not affect layout 3D Transforms translate, scale, rotate, skew in X, Y & Z perspective
  • 107. CSS3 Transforms Essentials Rendering and computations are made on GPU Applies to any DOM element Declarative and programmatic control
  • 108. HTML5 CSS Custom Shaders User supplied program for GPU programming Executes in parallel Source of awesome visual effects Programmed in GLSL
  • 112. CSS Custom Shaders Fragment Shader GPU program for pixel color manipulation The result is a pixel color Executes in parallel on GPU infrastructure Currently there is no way to set via gl_FragColor
  • 113. Fragment Shader Sample precision mediump float; void main() { float r = 1.0; float g = 1.0; float b = 1.0; float a = 1.0; css_ColorMatrix = mat4( r, 0.0, 0.0, 0.0, 0.0, g, 0.0, 0.0, 0.0, 0.0, b, 0.0, 0.0, 0.0, 0.0, a ); }
  • 114. CSS Custom Shaders Vertex Shader Responsible for mesh deformations The result is a vertex position Executes in parallel on GPU infrastructure
  • 115. Vertex Shader Sample precision mediump float; attribute vec4 a_position; uniform mat4 u_projectionMatrix; void main() { gl_Position = u_projectionMatrix * a_position; } Projection matrix is supplied by a web browser. a_position stores vertex position
  • 116. CSS Custom Shaders Syntax #myelement { filter: custom( vertex-shader [ fragment-shader] [,vertex-mesh] [,params]); } How to apply shader?
  • 117. CSS Custom Shaders Vertex Creation #myelement { filter: custom( vertex-shader [ fragment-shader] ,4 5 [,params]); } How to apply shader?
  • 118. CSS Custom Shaders Uniforms #myelement { filter: custom( vertex-shader [ fragment-shader] ,4 5 , amount 0); } CSS precision mediump float; uniform float amount; void main(){ } Fragment Shader
  • 119. WebGL Essentials It is a software library that extends the capability of the JavaScript to allow it to generate 3D graphics Uses canvas as rendering surface Based on OpenGL ES 2.0
  • 121. WebGL Support “We believe that WebGL will likely become an ongoing source of hard-to-fix vulnerabilities. In its current form, WebGL is not a technology Microsoft can endorse from a security perspective.” Microsoft June 16, 2011
  • 122. WebGL Support “I agree with Microsoft’s assessment that WebGL is a severe security risk. The gfx driver culture is not the culture of security.” John Carmack Co-founder of Id Software, June 2011
  • 124. Typed Arrays Essentials Efficient way to pass data into API`s C-like arrays Memory can be passed directly to native API`s
  • 125. Typed Arrays Array Buffer Abstract representation of binary data Serves as a data-source for typed arrays Integrated with other HTML API`s
  • 126. Typed Arrays Array Buffer View Int8Array Uint8Array Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Uint8ClampedArray
  • 127. Typed Arrays Data View Simplifies manipulations with heterogeneous types Supports big and little endian Be careful with alignment
  • 128. Typed Arrays Interoperability WebGL Canvas 2D File API Web Sockets XHR2 Media Source Transferable objects
  • 129. Same Origin Policy Go to full specification Security Browser-level Firewall Prohibits sending security sensitive information to foreign locations Prohibits read of resources from foreign origin Primary security barrier against XSS and Cookie stealing attacks What is same origin policy?
  • 130. Same Origin Policy Go to full specification Security What origins are foreign? http://www.example.com Same protocol and host but different port http://www.example.com:81 Different protocol https://www.example.com Different host http://en.example.com
  • 131. Web Messaging Essentials Go to full specification Mechanism for cross-document communication Support for cross-origin communication API for exchanging plain text messages and structured data What is Web Messaging?
  • 132. Web Messaging Communication Go to full specification Window object Message Channel
  • 133. Web Messaging Essentials Go to full specification The end of iframe hacks!
  • 134. Web Messaging API Go to full specification postMessage() – to post message to window Message event – event raised when new message arrived
  • 135. Web Workers Go to full specification JavaScript is inherently single threaded Asynchronous through single message loop No concurrency, no thread synchronization Motivation
  • 136. Web Workers Issue Go to full specification “[JavaScript] that executes in whole seconds is probably doing something wrong...” Brendan Eich Creator of JavaScript, Mozilla Foundation
  • 137. Web Workers Effect Go to full specification
  • 138. Web Workers Old-school solutions Go to full specification Partition work with timers Offload work to server
  • 139. Web Workers Essentials Go to full specification JavaScript native ‘threading’ mechanism True parallelism Designed to be long-lived High startup cost performance and memory cost What are Web Workers?
  • 140. Web Workers Essentials Go to full specification Loaded from separate file or Blob Communication with parent script through messages and events Can be terminated from inside and outside Due to their multi-threaded behavior, web workers only has access to a subset of DOM and BOM features How it works?
  • 141. Web Workers Scope Go to full specification The navigator object The location object (read-only) XMLHttpRequest setTimeout(), setInterval() The application cache Importing external scripts using the importScripts() method Spawning other Web Workers Features Available to Workers
  • 142. Web Workers Scope Go to full specification DOM and BOM window object document object parent object Features Unavailable to Workers
  • 143. Web Workers Types Go to full specification Dedicated Shared
  • 144. Web Workers Transferable Objects Go to full specification Structured data can be passed without copying Huge performance win Supported structured objects: ArrayBuffer MessagePort CanvasProxy
  • 145. Web Workers Transferable Objects Go to full specification
  • 146. HTML5 Go to full specification Real-time Communications HTTP protocol has one request – one resource semantics No built-in mechanism for Push Notifications Semi-duplex communications Overhead of HTTP headers
  • 148. Real-time Go to full specification Use cases Multiplayer games
  • 149. Real-time Go to full specification Use cases Live sync applications
  • 151. Real-time Go to full specification Polling Periodic HTTP requests High server workload High latency High degree of support across different browsers
  • 154. Real-time Go to full specification Comet Periodic long-lived HTTP requests Reduced traffic Reduced server workload Overhead of HTTP headers Possible difficulties with proxies and load balancers
  • 157. Web Sockets Go to full specification Essentials Full-duplex socket connection Web Socket protocol v13 (RFC 6455) instead of HTTP Uses HTTP for connection establishment Low-latency client-server communication technology
  • 158. Web Sockets Go to full specification Connection Establishment Runs via port 80/443 to simplify firewalls traversal Pseudo schemes: ws, wss Connection established by “upgrading” from HTTP to WebSocket protocol
  • 159. Web Sockets Go to full specification Opening handshake GET /chat HTTP/1.1 Host: server.example.com Upgrade: websocket Connection: Upgrade Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== Origin: http://example.com Sec-WebSocket-Protocol: chat, superchat Sec-WebSocket-Version: 13 Client sends GET or CONNECT request to Web Socket endpoint Upgrade header indicates willing to upgrade connection from HTTP to WebSocket
  • 160. Web Sockets Go to full specification Opening handshake HTTP/1.1 101 Switching Protocols Upgrade: websocket Connection: Upgrade Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo= Server responds with 101 status code and connection upgrade header From now on Web Socket protocol will be used instead of HTTP
  • 161. Web Sockets Go to full specification API var connection = new WebSocket('ws://html5rocks.websocket.org/echo'); Connection Communication // When the connection is open, send some data to the server connection.onopen = function () { // Send the message 'Ping' to the server connection.send('Ping'); }; // Log errors connection.onerror = function (error) { // Log messages from the server console.log('WebSocket Error ' + error); }; connection.onmessage = function (e) { console.log('Server: ' + e.data); };
  • 162. Server-sent Events Go to full specification Essentials Support for auto reconnect Support for event ids Requires Content-Type: text/event-stream Browser built-in long polling mechanism
  • 163. Server-sent Events Go to full specification Essentials data: This is the first message. data: This is the second message, it data: has two lines. data: This is the third message. Response event: add data: 73857293 event: remove data: 2153 event: add data: 113411 Response with named Events
  • 164. XHR Level 2 Go to full specification Essentials What is XHR? API for sending HTTP and HTTPS requests directly to Web Server Supports plain text and structured response formats Interaction without page refresh Basement of AJAX
  • 165. XHR Level 2 Go to full specification Interaction Model AJAX JavaScript Document Object Model XHR Asynchronous Web calls DHTML manipulations
  • 166. XHR Level 2 Go to full specification Security Strong security concerns Same origin policy Cross-origin resource sharing policy
  • 167. XHR Level 2 Go to full specification Security Cross-origin communication scenarios JSONP CORS Blind Proxies Web Messaging Iframe hacks HTTP forgery
  • 168. XHR Level 2 Go to full specification Security Way for a web server to allow its resources to be accessed by a web page from a different domain Requires server & client side support Server side decides which origins are allowed HTTP header based negotiation What is cross-origin resource sharing?
  • 169. XHR Level 2 Go to full specification Security
  • 170. XHR Level 2 Go to full specification Security Request GET http://photos.contoso.com/albums HTTP/1.1 Origin: http://www.contoso.com Origin header specifies that this is CORS aware request. Response HTTP/1.1 200 OK Access-Control-Allow-Origin: http://www.contoso.com Server respond with special header that allows browser to consume such response
  • 171. XHR Level 2 Go to full specification Security Request OPTIONS http://photos.contoso.com/albums HTTP/1.1 Origin: http://www.contoso.com Access-Control-Request-Method: PUT In case of non-safe methods web browser should send preflight request prior to sending actual request Response HTTP/1.1 200 OK Access-Control-Allow-Origin: http://www.contoso.com Access-Control-Allow-Methods: PUT Server respond with special header that allows browser to make actual request
  • 172. XHR Level 2 Go to full specification Features Cross-origin requests Uploading progress events Uploading downloading structured data
  • 173. XHR Level 2 Go to full specification Features Structured data Allows to get resources as structured object Allows to post data as structured object Controlled via responseType property New response property to consume resource in structured format
  • 174. XHR Level 2 Go to full specification Features Structured formats (upload) ArrayBuffer – generic fixed-length binary data buffer FormData – object based representation of form fields Blob – url accessible container for binary data Document DOMString – plain text response
  • 175. XHR Level 2 Go to full specification Features Structured formats (download) arraybuffer – generic fixed-length binary data buffer blob – url accessible container for binary data document text – plain text response json – json string converted into object
  • 176. XHR Level 2 Go to full specification Features Structured data var xhr = new XMLHttpRequest(); xhr.open('GET', '/path/to/image.png', true); xhr.responseType = 'arraybuffer'; xhr.onload = function(e) { var uInt8Array = new Uint8Array(this.response); var byte3 = uInt8Array[4]; // byte at offset 4 ... }; xhr.send(); GET example
  • 177. Geolocation Essentials Go to full specification Mechanism for determining user geographic coordinates Available on desktop and mobile devices Uses GPS, A-GPS, Wi-Fi hotspots or IP address range to determine current coordinates Easy to use JavaScript API Strong security concerns What is Geolocation?
  • 178. Geolocation API Go to full specification Main object – navigator.geolocation getCurrentPosition – gets current position & speed (if possible) watchPosition – track position changes clearWatch – stop tracking position changes
  • 179. Device Orientation Essentials Mechanism for determining Euler`s angles (rotation around X,Y, Z) Supported on broad variety of mobile devices What is device orientation? The deviceorientation event with orientation data passed along The devicemotion event with orientation and acceleration data passed along
  • 180. Application Cache Essentials Go to full specification Software storage feature which provides the ability to access a web application even without a network Controlled by a plain text file called a cache manifest Can be managed by JavaScript API What is Web Application Cache?
  • 181. Application Cache Manifest file Go to full specification Contains a list of resources to be stored for use when there is no network connectivity Defines conditions for caching Consist of sections CACHE – a list of explicit urls to request and store FALLBACK - What to do when an offline user attempts to access an uncached file NETWORK – Which resources are available only when online
  • 182. Application Cache Manifest file Go to full specification <!DOCTYPE HTML> <html manifest="/cache.appcache"> <body> … </body> </html> Page markup CACHE MANIFEST # This is a comment CACHE: /css/screen.css /css/offline.css /js/screen.js /img/logo.png http://example.com/css/styles.css FALLBACK: / /offline.html NETWORK: * Manifest file
  • 183. CSS 3
  • 184. Graphics Features Transparency color specification with alpha, opacity property Round corners border-radius Shadows box-shadow, text-shadow Background gradients linear, radial Typography Web Open Font Format (WOFF) fonts
  • 185. 2D & 3D Transforms Display-time transformations of any HTML content transforms do not affect layout 2D Transforms translate, scale, rotate, skew 3D Transforms translate, scale, rotate, skew in X, Y & Z perspective
  • 186. Animations & Transitions Transitions smooth animation of CSS properties from old to new value can be used with CSS pseudo-classes such as :hover Animations keyframe-based definition of a set of CSS property changes allows richer animations than CSS Transitions event model allows complex use in combination with script
  • 187. Animations & Transitions #id_of_element { -webkit-transition: all 1s ease-in-out; -moz-transition: all 1s ease-in-out; -o-transition: all 1s ease-in-out; -ms-transition: all 1s ease-in-out; transition: all 1s ease-in-out; } Transition @keyframes resize { 0% { padding: 0; } 50% { padding: 0 20px; background-color:rgba(255,0,0,0.2); } 100% { padding: 0 100px; background-color:rgba(255,0,0,0.9); } } #box { animation-name: resize; animation-duration: 1s; animation-iteration-count: 4; animation-direction: alternate; animation-timing-function: ease-in-out; } Animation
  • 188. Markup
  • 189. New Tags Semantic Input types Multimedia Other
  • 190. New Tags <article> Specifies independent, self-contained content, could be a news-article, blog post, forum post, or other articles which can be distributed independently from the rest of the site. <aside> For content aside from the content it is placed in. The aside content should be related to the surrounding content <bdi> For text that should not be bound to the text-direction of its parent elements <command> A button, or a radiobutton, or a checkbox <details> For describing details about a document, or parts of a document <summary> A caption, or summary, inside the details element <figure> For grouping a section of stand-alone content, could be a video <figcaption> The caption of the figure section <footer> For a footer of a document or section, could include the name of the author, the date of the document, contact information, or copyright information <header> For an introduction of a document or section, could include navigation <hgroup> For a section of headings, using <h1> to <h6>, where the largest is the main heading of the section, and the others are sub-headings <mark> For text that should be highlighted <meter> For a measurement, used only if the maximum and minimum values are known <nav> For a section of navigation <progress> The state of a work in progress <ruby> For ruby annotation (Chinese notes or characters) <rt> For explanation of the ruby annotation <rp> What to show browsers that do not support the ruby element <section> For a section in a document. Such as chapters, headers, footers, or any other sections of the document <time> For defining a time or a date, or both <wbr> Word break. For defining a line-break opportunity.
  • 194. Input Types 13 new input types Built-in client-side validation Poor support in desktop browsers See browser compatibility information
  • 195. Input Types search tel url email datetime date month week time datetime- local number range color
  • 196. HTML5 Feature detection Never use navigator.userAgent browser detection hack Never use conditional comment in Internet Explorer Use feature detecting instead of browser detection when possible Consider graceful fallback Use Modernizr
  • 197. Feature detection Modernizr Modernizr is a small JavaScript Library that detects the availability of native implementations for next-generation web technologies What is Modernizr? Why Modernizr? Easy to use Powerfull feature detection library
  • 198. Feature detection Modernizr Modernizr does its “magic” by creating an element, setting a specific style instruction on that element and then immediately retrieving it How it works? Feature detection results available to developer via JavaScript Modernizr object and classes applied to HTML DOM element
  • 199. Feature detection Modernizr How it looks like? /* In your CSS: */ .no-audio #music { display: none; /* Don't show Audio options */ } .audio #music button { /* Style the Play and Pause buttons nicely */ } <!-- In your HTML: --> <div id="music"> <audio> <source src="audio.ogg" /> <source src="audio.mp3" /> </audio> <button id="play">Play</button> <button id="pause">Pause</button> </div>
  • 200. Links Useful HTML5 content http://www.html5rocks.com HTML5 news, demos, presentations http://www.html5doctor.com Lot of HTML5 tutorials, articles http://ie.microsoft.com/testdrive/Graphics/h ands-on-css3/ HTML5 Hands-On