75
Upgrade Your Website to HTML5 Upgrade Your Website to HTML5 Raj Lal Raj Lal Senior Engineer, Nokia Level: Intermediate

Upgrade Your Website to HTML5 - VSLive Conference New York @iRajLal

  • Upload
    raj-lal

  • View
    2.752

  • Download
    4

Tags:

Embed Size (px)

DESCRIPTION

Learn what you need to do, to upgrade your existing web application with HTML5. How and Where do you start? Learn how you capitalize on the State-of-the-Art HTML5 tags, Cutting edge graphics and animation with CSS3, and advanced HTML5 API and take your existing website to the next level of Web revolution. You will learn: Upgrade your current website with HTML5 Use advanced HTML5 APIs which gracefully degrade Know how to enhance your website with the latest HTML5 goodies

Citation preview

Page 1: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Upgrade Your Website to HTML5Upgrade Your Website to HTML5

Raj LalRaj LalSenior Engineer, Nokia

Level: Intermediate

Page 2: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Story of a Story of a Web GuyWeb Guy

Page 3: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Story of a Web GuyStory of a Web Guy

About Tools Upgrade

Page 4: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

1. About1. About

AboutRequirements

Concerns

Page 5: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

About the Web GuyAbout the Web Guy

1. Develop & design websites

2. Manage multiple websites

3. Knows Web stuff

Page 6: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Web StuffWeb Stuff

RIARIAHTML 4

ajax

flashXHTML

cookies

HTMLsandbox

Validation

Silverlight

web 2.0

Client Server

Media playerjquery

ASP/PHPWeb application

Browser wars

JavaScript

CSS<TABLE>

widgetsPlug-ins

Page 7: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Old HTML

Web Application

Web 2.0

Page 8: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Old HTML

Web Application

Web 2.0

HTML5

Page 9: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

HTML5HTML5

W3CCanvasCanvas

article

Offline

Transition

@font-face

Web worker

Audio/videoviewport

HTML Validation

App Cache

web db

Animation

SVGWeb socket

Web App

Cross browser

Geo location

Storage Threads

CSS3Plug-ins

APIs

Page 10: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

How do I upgrade?How do I upgrade?

Page 11: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

RequirementsRequirements

1. User Experience

2. Availability

3. Accessibility

4. Cutting edge

Page 12: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

ConcernsConcerns

1. How do I upgrade to HTML5

2. New Website ?

3. Compatibility with old website?

4. Break existing websites ?

Page 13: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

2. Tools2. Tools

InformationTools

Page 14: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

2. Tools2. Tools

Page 15: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Tools 1: Tools 1: Progressive EnhancementProgressive Enhancement

Page 16: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Tools 2: Tools 2: Understand CSSUnderstand CSS

1. CSS is parsed sequentially

2. The last style is the final style

3. Browser ignore unknown syntax

Page 17: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Tools 2: Tools 2: Understand CSSUnderstand CSS

.style{ background-color: rgb(100,214,120) background-color: rgba(100,214,120, .5)}

Page 18: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Tools 2: Tools 2: Understand CSSUnderstand CSS

Advanced Styles with CSS3

• Background• Border Radius• Drag and Drop• Opacity• Transformation• …

Page 19: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Tools 2: Tools 2: Understand CSSUnderstand CSS

Prefix•-ms-•-moz-•-o-•-webkit-

Page 20: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Tools 2: Tools 2: Understand CSSUnderstand CSS

.style{-moz-border-radius: 1em;-ms-border-radius: 1em;-o-border-radius: 1em;-webkit-border-radius: 1em;border-radius: 1em;}

Page 21: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Tools 2: Tools 2: Understand CSSUnderstand CSS

#style{Width:800px;Height:640px;}

Body [id=enhanced] #style{Width:100%;Height:640px;}

<body><div id=“enhanced” class=“Style”></div></body>

HTML CSS

Page 22: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Tools 3: Tools 3: Feature DetectionFeature Detection

Old method New method

Page 23: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Tools 3: Tools 3: Feature DetectionFeature Detection

Page 24: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Tools 3: Tools 3: Feature DetectionFeature Detection

Use libraries

• Modernizr

• jQuery.support

Page 25: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Tools 3: Tools 3: Feature DetectionFeature Detection

<script src="modernizr-1.7.js“/>Modernizr.canvas ? "Canvas" : “Nocanvas";

<script src="jquery-latest.js“/>jQuery.support.ajax ? "Ajax" : “No Ajax";

Page 26: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Tools 3: Tools 3: Feature DetectionFeature Detection

Modernizr

Canvas SVG Cross Window Msg

Audio InlineSVG Web Workers

Video WebGL Web SQL database

Animation Websockets Touch

Transformation Geolocation

Drag and Drop Local Storage

Page 27: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Tools 3: Tools 3: Feature DetectionFeature Detection

jQuery.Support

Ajax

Cross Domain Resource Sharing (CORS)

Fixed Position

CSS Opacity

CSS Float

htmlNormalize

Page 28: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Tools 3: Tools 3: Feature Detection Feature Detection

http://widgets-gadgets.com/html5/

Demo

Page 29: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

3. Upgrade3. Upgrade

Upgrade

Page 30: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Requirements of Web GuyRequirements of Web Guy

1. Better User Experience

2. Available Everywhere

3. Make it Accessible

4. Cutting edge Graphics and Animation

Page 31: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Upgrade 1: Upgrade 1:

Deliver Richer UXDeliver Richer UX

Page 32: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

1: Deliver Richer UX1: Deliver Richer UX

I. Enhance you Homepage

II. Add Media

Page 33: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Rich UX to HomepageRich UX to Homepage

What is common?

http://micrsoft.com

http://amazon.com

http://linkedin.com

Page 34: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Answer: Slideshow

Page 35: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Upgrade 1: Upgrade 1: Add a slideshow Add a slideshow

By Ian Hansson

Responsive CSS3 Slider

Page 36: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Upgrade 1: Upgrade 1: Add a slideshow Add a slideshow

Ian Hansson (@teapoted)

HTML

<input type="radio" name="slider" id="slide1"><input type="radio" name="slider" id="slide2">

Page 37: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

<div id=‘s’><div class="inner">

<article><div class="info"></div></article>

<article><div class="info"></div></article>

</div></div>

Upgrade 1: Upgrade 1: Add a slideshow Add a slideshow

HTML

Page 38: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Upgrade 1: Upgrade 1: Add a slideshow Add a slideshow

#s .inner { width: 200%; }#s article {width: 50%;float: left;}

#slide1:checked s.inner{ margin-left:0; } #slide2:checked s.inner{ margin-left:-100%;}

Ian Hansson (@teapoted)

CSS

Page 39: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

UP 2: Rich UX with MediaUP 2: Rich UX with Media

Page 40: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Upgrade 2: Upgrade 2:

Available EverywhereAvailable Everywhere

Page 41: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Upgrade 2: AvailabilityUpgrade 2: Availability

I. To all devices

I. PC

II. TV

III. Mobile

IV. Tablet

II. All Screen size

Page 42: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

All Devices: Layout Detection

OPTIONS AVAILABLE

Page 43: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Layout Detection: Media Queries

Media-queries enable style sheets tailored for

different ’width’, ‘height’ and ‘color’

Page 44: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Layout Detection: Media Queries

<link rel="stylesheet" href="handheld.css" media="only screen and (max-width: 480px), handheld" />

<link rel="stylesheet" href="default.css" media="screen" />

<link rel="stylesheet" href="wider.css" media="only screen and (min-width: 1200px)" />

Page 45: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Layout Detection: Media Queries

http://www.lancs.ac.uk/

handheld Default screen Wider screen

Page 46: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Layout Detection: Media Queries

Media Query for device-aspect-ratio

@media screen and (device-aspect-ratio: 16/9) @media screen and (device-aspect-ratio: 32/18) @media screen and (device-aspect-ratio: 1280/720) @media screen and (device-aspect-ratio: 2560/1440)

Page 47: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Layout Detection: Media Queries

Media Query for Orientation

@media screen and (orientation:portrait) { /* Portrait styles */}@media screen and (orientation:landscape) { /* Landscape styles */}

Page 48: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Layout Detection: ViewPort

Viewable area on the screen

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

Page 49: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Layout Detection: JavaScript

<script src="jquery.mediaqueries.js“></script>

The script adds basic Media Query-Support (min-width and max-width in px units ) to all browsers 

jQuery.mediaqueries

Page 50: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Upgrade 3: Upgrade 3:

Make it Accessible Make it Accessible

Page 51: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

UP 3: Accessibility: UP 3: Accessibility: Easier to UseEasier to Use

Helps Disabled

LimitedResources

Search Engines

Page 52: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

UP 3: Accessibility: UP 3: Accessibility: Easier to UseEasier to Use

4 Key Areas for HTML5 Developers

• Hearing

• Mobility

• Cognitive

• Visual

Page 53: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

UP 3: Accessibility: UP 3: Accessibility: Easier to UseEasier to Use

W3C recommends POUR Principle

• Perceivable

• Operable

• Understandable

• Robust

Page 54: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

UP 3: Accessibility: UP 3: Accessibility: Easier to UseEasier to Use

1/4 Hearing

• Problem

Cannot hear media

•Solution

Make it PERCEIVABLE

Page 55: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

UP 3: Accessibility: UP 3: Accessibility: Easier to UseEasier to Use

PERCEIVABLE

• Text alternative to all non-text content • Alternative for media using, subtitles,

transcribed text

• Semantic Markup with separation of, Style & Content

1/4 Hearing

Page 56: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

UP 3: Accessibility: UP 3: Accessibility: Easier to UseEasier to Use

2/4 Mobility

• Problem

Difficulty with Mouse Keyboard

•Solution Make it OPERABLE

Page 57: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

UP 3: Accessibility: UP 3: Accessibility: Easier to UseEasier to Use

2/4 Mobility

OPERABLE

•All function accessible from keyboard alone

•No auto refresh, allow stop time based contents

•Navigate with proper use of Headings & Anchors

•Joysticks ,Voice recognition or audio feedback

Page 58: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

UP 3: Accessibility: UP 3: Accessibility: Easier to UseEasier to Use

3/4 Cognitive

• Problem

Difficulty with Text content

• Solution

Make it UNDERSTANDABLE

Page 59: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

MAKE IT UNDERSTANDABLE

• High contrast between front and background

• Allow san serif fonts and custom resizable font size

• Avoid auto-play animation, auto refresh, flashy images

• Important info, error not by color only

• Use multiple visual cues, std. icons,

UP 3: Accessibility: UP 3: Accessibility: Easier to UseEasier to Use

Page 60: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

UP 3: Accessibility: UP 3: Accessibility: Easier to UseEasier to Use

4/4 Visual

• Problem

Cannot see the content

Differentiate color

• Solution

Make it ROBUST

Page 61: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

4/4 Visual

ROBUST

• Broken HTML tag cause difficulty in screen reader

• Follow HTML standard specifications

• Use syntactically correct HTML & validate web page

• Proper “lang” attributes in the markup

• Use “acronym” and “abbr” tag with proper usage

Page 62: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

UP 3: Accessibility: UP 3: Accessibility: Easier to UseEasier to Use

Use Semantic Markup

Page 63: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

UP 3: Accessibility: UP 3: Accessibility: Easier to UseEasier to Use

Use HTML5 Elements

ARIA Roles <nav role=”navigation”>

CSS: No Fixed Font size

Page 64: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Upgrade 4: Upgrade 4:

Cutting EdgeCutting Edge

Page 65: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

UPGRADE 4: Cutting EdgeUPGRADE 4: Cutting Edge

I. Advanced graphics and animation

II. HTML5 APIs

I. Geolocation

II. Communication APIs

III. Web Socket

IV. Etc.

Page 66: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Requirement 4 : Requirement 4 : CSS3 AnimationCSS3 Animation

Page 67: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Animation: SVG

• 2D vector graphics using XML• Object retained in the memory• Full DOM support• SVG elements can be styled• Check Modernizr.svg Modernizr.inlinesvg

Perform better when smaller number of elements and large surface

Page 68: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Animation: SVG

<svg id="svgElement" width="800px" height="600px" viewBox="0 0 800 600">

<rect x="0" y="0" width="100%" height="100%" rx="10" ry="10" style="fill: white; stroke: black;" />

<circle id="circle0" cx="40" cy="40" r="40" style="fill: orange; stroke: black; stroke-width: 1;" /></svg>

HTML CODE

Page 69: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Animation: Canvas: Context 2D

• Bitmap drawing area• Rectangles, lines, arcs, paths• Stateless • No DOM support, single element• Check Modernizr.canvas

Perform better when large number of objects and surface is small

Page 70: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Animation: CSS3

• Styles for Individual elements• Use CSS3 animation if available• Better than JavaScript based animation• Check Modernizr.csstransitions

Can perform better with GPU acceleration

Page 71: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

#myelement{ …-ms-transition: opacity 1s ease;transition: opacity 1s ease;}

Animation: CSS3

var elem = $(‘myelement');

elem.addEventListener('click', function loop() { elem.style.left = ‘100px';}, false);

JS CODE

CSS

Page 72: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Advanced HTML5 APIs

Page 73: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

HTML5 API: Polyfills and Shims?

• Polyfills: Replicate standard feature API

• Shims: Own API with useful features

Provide support for missing features.

Page 74: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Summary

• Upgrade to a Rich User Experience

• Adding slideshow, rich media and advanced css

• Available to All devices

• Using Viewport, MediaQueries, Orientations

• Upgrade to accessible Website

• Ensuring 4 key accessible areas

• Upgrade to CSS3 Animation & Adv. HTML5 APIs

Page 75: Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal

Thank YouThank You

Raj LalRaj LalSenior Engineer, Nokia

Twitter @ iRajLal