SlideShare a Scribd company logo
HTML5 on Mobile (For Developer)

               Adam Lu
         http://adamlu.com/
Mobile is Growing
• In January 2012, 8.49 percent of website
  hits/pageviews come from a handheld mobile
  device (StatCounter)
• Mobile will be bigger than desktop internet in
  5 years (Morgan Stanley)
• 2.1 billion mobile devices will have HTML5
  browsers by 2016 up from 109 million in 2010
  (ABI Research)
Mobile is Growing




   Source: Nielsen (January 2012)
HTML5 is Great for Mobile
• Do not need download to use Web App
• One Code base, all popular devices
• Tons of great HTML5 features are already
  supported on modern browsers
Web App vsNative App
        Web App                      Native App                  Comparation
    Just enter the URL          Must be deployed or           Installation/updates
                                   downloaded
 Access to web analytics.       Apple Store, Android             Monetization
 Rate,SaaS based revenue          Market, Rating

Progressive Enhancement         Follow the standards          End User Experience

  GeoLocation, Offline          camera, gyroscope,         Access to hardware sensors
Storage, Canvas Graphics,      microphone, compass,
      Audio, Video,             accelerometer, GPS
  Camera(Android3.1+)
HTML5, CSS3, Javascript, UI   Object-C, Java, C++, J2EE,     Developer Experience
         Library                 .NET, Cocoa Touch
  Web Workers, Graphic        Run directly on the metal,         Performance
  acceleration, WebGL         GPU Acceleration, Multi-
                                      Threading
Mobile Users prefer browsers over
              apps




            (source: Adobe)
What is HTML5
What is HTML5




Forms, Communication, Canvas, Geolocation,
Web Applications, Audio, WebGL, Microdata,
Video, Workers, Files, Elements, Storage, Local
Devices, User interaction, Parsing rules, …
Build Mobile Web with HTML5
• Decide which platforms/browsers you will
  support

                    -ms-
                              Webkit on Mobile?
                     -o-
                              There is no webkit on mobile
                    -moz-     http://quirksmode.org/webkit.html

                   -webkit-
Build Mobile Web with HTML5
• HTML Markup
 <!DOCTYPE html>                                 Semantic HTML:
 <html>                                          <section>
 <head>                                          <article>
 <meta charset="utf-8" />                        <nav>
 <meta name="viewport"                           <aside>
 content="width=device-width, initial-scale=1,   <header>
 maximum-scale=1, user-scalable=no">             <progress>
 <link rel="apple-touch-icon"                    <time>
 href="images/favicon.png" />                    …
 </head>                                         Basic Setting:
 <body>                                          Set Viewport
 </body>                                         Turn off user-scaling
 </html>                                         Set favicon …

 http://www.w3.org/wiki/HTML/Elements
Build Mobile Web with HTML5
  • CSS Reset
-webkit-text-size-adjust: none;
-webkit-user-select: none;
-webkit-touch-callout;
-webkit-tap-highlight-color: transparent;
audio, canvas, video { display: inline-
block;
}
article, aside, details, figcaption, figure,
footer, header, hgroup, nav, section {
display: block; }
input[type="search"]{ -webkit-
appearance: none/textfield;}
Build Mobile Web with HTML5
• Media Queries   /*styles for 800px and up!*/
                  @media only screen and (min-width: 800px) {
                    /* Styles */
                  }
                  /* iPhone 4, Opera Mobile 11 and other high
                  pixel ratio devices ----------- */
                  @media
                  only screen and (-webkit-min-device-pixel-
                  ratio: 1.5),
                  only screen and (-o-min-device-pixel-ratio:
                  3/2),
                  only screen and (min--moz-device-pixel-ratio:
                  1.5),
                  only screen and (min-device-pixel-ratio: 1.5) {
                    /* Styles */
                  }
Build Mobile Web with HTML5
 • CSS3 Effect


<input id="p" type="search"
autocorrect="off" autocomplete="off"
autocapitalize="off"
placeholder="Search" />
border-image: url() 0 24 stretch
box-shadow: #9FA1A4 0 3px 4px 2px        -webkit-border-radius: 5px;
inset                                    background: #FFAB23 -webkit-
border-radius: 15px;                     gradient(linear,0% 0,0%
background: -webkit-linear-gradient();   100%,from(#FE6),to(#FFAB23));
                                         box-sizing: border-box;
                                         http://mobile.twitter.com/session/new
Build Mobile Web with HTML5
• Make Animation

                                     CSS3 Animation instead of JS Animation

                                     transition: left 1s ease-in-out;

 http://jsfiddle.net/adamlu/RE6dF/   YUI().use(‘transition’, function(){});


                                     #box1, #box2{
                                         -webkit-transition: all 2s ease-in-out;
                                     }
                                     #box1:hover + #box2 {
                                        -webkit-transform: rotate(360deg);
                                        left: 500px;
 http://jsfiddle.net/adamlu/t5Afm/   }​
Build Mobile Web with HTML5
• Advanced Forms in Mobile
 <input type="number" pattern="[0-9]*" />
 <input type="email” required />
 <input type="url" />
 <input type="tel" />
 <input type="time" />
 <input type="date" />
 <input type="month" />
 <input type="week" />
 <input type="datetime" />
 <input type="datetime-local" />
 <input type="color" />

 http://jquerymobile.com/demos/1.1.0-
 rc.1/docs/forms/textinputs/
Build Mobile Web with HTML5
    • Graphic Drawing - Canvas & SVG
    http://jsfiddle.net/adamlu/xFR4V/         <canvas id="a" width="300"
                                              height="225"></canvas>
                                              vara_canvas = document.getElementById("a");
                                              vara_context = a_canvas.getContext("2d");
                                              a_context.fillRect(50, 25, 150, 100);


                                              <svgxmlns="http://www.w3.org/2000/svg"
                                              version="1.1">
                                              <circle cx="100" cy="50" r="40"
                                              stroke="black" stroke-width="2" fill="red" />
                                              </svg>
    http://jsfiddle.net/adamlu/W67j8/

http://www.limejs.com/static/roundball/index.html
Build Mobile Web with HTML5
• Media Support
                  <video poster="" src="" width="2"
                  height="1" x-webkit-
                  airplay="allow"></video>

                  <audio controls preload="auto"
                  autobuffer>
                  <source src="elvis.mp3" />
                  <source src="elvis.ogg" />
                  </audio>
Build Mobile Web with HTML5

• Geolocation API
                                                   Position Object
  navigator.geolocation.getCurrentPosition(succe
  ss, failure, options);




  PERMISSION_DENIED (1)
  POSITION_UNAVAILABLE (2)
  TIMEOUT (3)
  UNKNOWN_ERROR (0)
Build Mobile Web with HTML5
• Javascript Events
 window.addEventListener("touchstart", function(e){
 //e.touches;
 }, false);
 window.addEventListener("orientationchange", function(e){
 //window.orientation(0 is portrait, 90 and -90 are landscape)
 }, false);
 window.addEventListener("deviceorientation", function(e){
 //e.alpha
 //e.beta
 //e.gamma
 }, false);
 window.addEventListener("devicemotion", function(e){
 //e.acceleration.x/y/z
 //e.accelerationIncludingGravity.x/y/z
 }, false);
http://www.html5rocks.com/en/tutorials/device/orientation/
Build Mobile Web with HTML5
• Device Support
  window.devicePixelRatio               HTML Media Capture:
  navigator.connection(Android2.2+)     <input type="file" accept="image/*"
  // contents of navigator.connection   capture="camera" />
  object                                <device type="media"></device>
  {
    "type": "3",                        <video autoplay></video>
    "UNKNOWN": "0",                     navigator.getUserMedia({video: true,
    "ETHERNET": "1",                    audio: true}, function(stream) {
    "WIFI": "2",                        var video =
    "CELL_2G": "3",                     document.querySelector('video');
    "CELL_3G": "4"                      video.src = stream;
  }                                     }, errorCallback);

  http://dev.w3.org/2011/webrtc/editor/getusermedia.html
Build Mobile Web with HTML5
• User Interaction
   Drag and Drop
   HTML Editing
   Session History   window.history.pushState(data, title, url);//Add
                      one history state into browser history and
                      update the URL in the browser window.
                      window.history.replaceState(state, title,
                      url);//Modify the current history entry instead
                      of creating a new one.
                      window.onpopstate = function(e){e.state;};//A
                      popstate event is dispatched to the window
                      every time the active history entry changes.
                      http://html5demos.com/history
Build Mobile Web with HTML5
• Performance
Offline Web Application Cache:
<html manifest="/cache.manifest">
AddType text/cache-manifest .manifest
CACHE MANIFEST
NETWORK/CACHE/FALLBACK:
LocalStorage/SessionStorage:
varfoo = localStorage.getItem("bar");
localStorage.setItem("bar", foo);
window.addEventListener("storage", handle_storage, false);
Web Workers:
var worker = new Worker('doWork.js');
worker.addEventListener('message', function(e) {
console.log('Worker said: ', e.data);
}, false);
worker.postMessage('Hello World'); // Send data to our worker.
Build Mobile Web with HTML5
• Communication
   Cross-document messaging
   Server-Sent Events(XHR2)
   Web Sockets
  conn = new WebSocket('ws://node.remysharp.com:8001');
  conn.onopen= function () {};
  conn.onmessage= function (event) {
    // console.log(event.data);
  };
  conn.onclose= function (event) {
  state.className = 'fail';
  state.innerHTML = 'Socket closed';
  };
  http://html5demos.com/web-socket
Build Mobile Web with HTML5
• Make Web App
                           Full screen mode:
                           <meta name="apple-mobile-web-app-capable"
                           content="yes" />
                           Native Look:
                           text-shadow box-shadow
                           multi backgrounds border-image
                           border-radius
                           rgba color gradient
                           transform transition
                           Mobile Behavior:
                           position: fixed; overflow: scroll;
                           touch/gesture/orientationchange event
                           Offline:
                           AppCache
                           LocalStorage
 http://adamlu.com/iEye/
Mobile Web App Strategy
• Evaluate your requirement
• Decide what app you’ll do
• A hybrid app maybe a good approach (Web
  App  Native App)
• Mobile-First Responsive Design
• Progressive Enhancement
• Lighter is better
Frameworks
• Boilerplate http://html5boilerplate.com/mobile
• Packaging frameworks
    http://phonegap.com/
    http://www.appmobi.com/
• Web application frameworks
    http://jquerymobile.com/
    http://yuilibrary.com/
    http://sproutcore.com/
    http://www.sencha.com/
    http://zeptojs.com/
• HTML5 Game frameworks
    http://www.limejs.com/
    http://craftyjs.com/
    http://impactjs.com/
Tools
• Debugging
    WEINRE
    WebKit Remote Debugging
• Emulators & Simulators
    Mobile Emulators and Simulators
    Android Emulator
    iOS Simulator
• Performance
    Mobile PerfBookmarklet
    http://www.blaze.io/mobile/
Compatibility
•   http://haz.io/
•   http://caniuse.com/
•   http://css3test.com/
•   http://css3generator.com/
•   http://css3info.com/
•   http://html5test.com/
•   http://css3please.com/
•   http://mobilehtml5.org/
•   http://quirksmode.org/m/
Inspiration
• http://mobile-patterns.com/ - Mobile UI
  Patterns
• http://pttrns.com- Another gallery of Mobile
  UI
• http://mobileawesomeness.com- the best in
  mobile web design and developer news.
Resources
•   http://diveintohtml5.info/
•   http://www.html5rocks.com/
•   http://html5demos.com/
•   http://www.mobilehtml5.com/
•   http://www.w3.org/TR/html5/
•   http://gs.statcounter.com/
HTML5 is the future of Mobile!
Thanks!

  @adamlu

More Related Content

What's hot

RESS – Responsive Webdesign and Server Side Components
RESS – Responsive Webdesign and Server Side ComponentsRESS – Responsive Webdesign and Server Side Components
RESS – Responsive Webdesign and Server Side Components
Sven Wolfermann
 
Web APIs & Apps - Mozilla
Web APIs & Apps - MozillaWeb APIs & Apps - Mozilla
Web APIs & Apps - MozillaRobert Nyman
 
jQuery Mobile and JavaScript
jQuery Mobile and JavaScriptjQuery Mobile and JavaScript
jQuery Mobile and JavaScript
Gary Yeh
 
SEE 2009: Improving Mobile Web Developer Experience
SEE 2009: Improving Mobile Web Developer ExperienceSEE 2009: Improving Mobile Web Developer Experience
SEE 2009: Improving Mobile Web Developer Experience
Tasneem Sayeed
 
HTML5 and the dawn of rich mobile web applications pt 1
HTML5 and the dawn of rich mobile web applications pt 1HTML5 and the dawn of rich mobile web applications pt 1
HTML5 and the dawn of rich mobile web applications pt 1James Pearce
 
HTML5 WebWorks
HTML5 WebWorksHTML5 WebWorks
HTML5 WebWorks
Raul Jimenez
 
Jquery mobile
Jquery mobileJquery mobile
Jquery mobile
Predhin Sapru
 
Dynamic User Interfaces for Desktop and Mobile
Dynamic User Interfaces for Desktop and MobileDynamic User Interfaces for Desktop and Mobile
Dynamic User Interfaces for Desktop and Mobilepeychevi
 
Planning Adaptive Interfaces [RWD Summit 2016]
Planning Adaptive Interfaces [RWD Summit 2016]Planning Adaptive Interfaces [RWD Summit 2016]
Planning Adaptive Interfaces [RWD Summit 2016]
Aaron Gustafson
 
Beyond Responsive [18F 2015]
Beyond Responsive [18F 2015]Beyond Responsive [18F 2015]
Beyond Responsive [18F 2015]
Aaron Gustafson
 
Device aware web frameworks for better programming
Device aware web frameworks for better programmingDevice aware web frameworks for better programming
Device aware web frameworks for better programming
Suntae Kim
 
Rich Portlet Development in uPortal
Rich Portlet Development in uPortalRich Portlet Development in uPortal
Rich Portlet Development in uPortal
Jennifer Bourey
 
HTML5: An Introduction To Next Generation Web Development
HTML5: An Introduction To Next Generation Web DevelopmentHTML5: An Introduction To Next Generation Web Development
HTML5: An Introduction To Next Generation Web Development
Tilak Joshi
 
Responsive images are here. Now what?
Responsive images are here. Now what?Responsive images are here. Now what?
Responsive images are here. Now what?
Jason Grigsby
 
Android ActionBar Navigation reloaded
Android ActionBar Navigation reloadedAndroid ActionBar Navigation reloaded
Android ActionBar Navigation reloaded
Dominik Helleberg
 
Metrics that Matter-Approaches To Managing High Performing Websites
Metrics that Matter-Approaches To Managing High Performing WebsitesMetrics that Matter-Approaches To Managing High Performing Websites
Metrics that Matter-Approaches To Managing High Performing Websites
Ben Rushlo
 
Modular applications with montage components
Modular applications with montage componentsModular applications with montage components
Modular applications with montage components
Benoit Marchant
 
One APK to rule them all
One APK to rule them allOne APK to rule them all
One APK to rule them all
Dominik Helleberg
 

What's hot (20)

RESS – Responsive Webdesign and Server Side Components
RESS – Responsive Webdesign and Server Side ComponentsRESS – Responsive Webdesign and Server Side Components
RESS – Responsive Webdesign and Server Side Components
 
Web APIs & Apps - Mozilla
Web APIs & Apps - MozillaWeb APIs & Apps - Mozilla
Web APIs & Apps - Mozilla
 
jQuery Mobile and JavaScript
jQuery Mobile and JavaScriptjQuery Mobile and JavaScript
jQuery Mobile and JavaScript
 
SEE 2009: Improving Mobile Web Developer Experience
SEE 2009: Improving Mobile Web Developer ExperienceSEE 2009: Improving Mobile Web Developer Experience
SEE 2009: Improving Mobile Web Developer Experience
 
HTML5 and the dawn of rich mobile web applications pt 1
HTML5 and the dawn of rich mobile web applications pt 1HTML5 and the dawn of rich mobile web applications pt 1
HTML5 and the dawn of rich mobile web applications pt 1
 
HTML5 WebWorks
HTML5 WebWorksHTML5 WebWorks
HTML5 WebWorks
 
Jquery mobile
Jquery mobileJquery mobile
Jquery mobile
 
Upload[1]
Upload[1]Upload[1]
Upload[1]
 
Dynamic User Interfaces for Desktop and Mobile
Dynamic User Interfaces for Desktop and MobileDynamic User Interfaces for Desktop and Mobile
Dynamic User Interfaces for Desktop and Mobile
 
Planning Adaptive Interfaces [RWD Summit 2016]
Planning Adaptive Interfaces [RWD Summit 2016]Planning Adaptive Interfaces [RWD Summit 2016]
Planning Adaptive Interfaces [RWD Summit 2016]
 
Beyond Responsive [18F 2015]
Beyond Responsive [18F 2015]Beyond Responsive [18F 2015]
Beyond Responsive [18F 2015]
 
Device aware web frameworks for better programming
Device aware web frameworks for better programmingDevice aware web frameworks for better programming
Device aware web frameworks for better programming
 
Rich Portlet Development in uPortal
Rich Portlet Development in uPortalRich Portlet Development in uPortal
Rich Portlet Development in uPortal
 
HTML5: An Introduction To Next Generation Web Development
HTML5: An Introduction To Next Generation Web DevelopmentHTML5: An Introduction To Next Generation Web Development
HTML5: An Introduction To Next Generation Web Development
 
Responsive images are here. Now what?
Responsive images are here. Now what?Responsive images are here. Now what?
Responsive images are here. Now what?
 
Android ActionBar Navigation reloaded
Android ActionBar Navigation reloadedAndroid ActionBar Navigation reloaded
Android ActionBar Navigation reloaded
 
Metrics that Matter-Approaches To Managing High Performing Websites
Metrics that Matter-Approaches To Managing High Performing WebsitesMetrics that Matter-Approaches To Managing High Performing Websites
Metrics that Matter-Approaches To Managing High Performing Websites
 
AspNetWhitePaper
AspNetWhitePaperAspNetWhitePaper
AspNetWhitePaper
 
Modular applications with montage components
Modular applications with montage componentsModular applications with montage components
Modular applications with montage components
 
One APK to rule them all
One APK to rule them allOne APK to rule them all
One APK to rule them all
 

Similar to Html5 on Mobile(For Developer)

Web Apps and more
Web Apps and moreWeb Apps and more
Web Apps and more
Yan Shi
 
Web app and more
Web app and moreWeb app and more
Web app and morefaming su
 
Multi screen HTML5
Multi screen HTML5Multi screen HTML5
Multi screen HTML5
Ron Reiter
 
Pinkoi Mobile Web
Pinkoi Mobile WebPinkoi Mobile Web
Pinkoi Mobile Web
mikeleeme
 
openMIC barcamp 11.02.2010
openMIC barcamp 11.02.2010openMIC barcamp 11.02.2010
openMIC barcamp 11.02.2010Patrick Lauke
 
Making your site mobile-friendly - DevCSI Reading 21.07.2010
Making your site mobile-friendly - DevCSI Reading 21.07.2010Making your site mobile-friendly - DevCSI Reading 21.07.2010
Making your site mobile-friendly - DevCSI Reading 21.07.2010
Patrick Lauke
 
[convergese] Adaptive Images in Responsive Web Design
[convergese] Adaptive Images in Responsive Web Design[convergese] Adaptive Images in Responsive Web Design
[convergese] Adaptive Images in Responsive Web DesignChristopher Schmitt
 
Bruce lawson-over-the-air
Bruce lawson-over-the-airBruce lawson-over-the-air
Bruce lawson-over-the-air
brucelawson
 
Html5
Html5Html5
Fake it 'til you make it
Fake it 'til you make itFake it 'til you make it
Fake it 'til you make it
Jonathan Snook
 
Mobile App Development
Mobile App DevelopmentMobile App Development
Mobile App DevelopmentChris Morrell
 
JavaONE 2012 Using Java with HTML5 and CSS3
JavaONE 2012 Using Java with HTML5 and CSS3JavaONE 2012 Using Java with HTML5 and CSS3
JavaONE 2012 Using Java with HTML5 and CSS3
Helder da Rocha
 
Responsive websites. Toolbox
Responsive websites. ToolboxResponsive websites. Toolbox
Responsive websites. Toolbox
Wojtek Zając
 
Jsf2 html5-jazoon
Jsf2 html5-jazoonJsf2 html5-jazoon
Jsf2 html5-jazoon
Roger Kitain
 
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
Sadaaki HIRAI
 
Responsive Websites
Responsive WebsitesResponsive Websites
Responsive Websites
Joe Seifi
 

Similar to Html5 on Mobile(For Developer) (20)

Web Apps and more
Web Apps and moreWeb Apps and more
Web Apps and more
 
Web app and more
Web app and moreWeb app and more
Web app and more
 
Multi screen HTML5
Multi screen HTML5Multi screen HTML5
Multi screen HTML5
 
Pinkoi Mobile Web
Pinkoi Mobile WebPinkoi Mobile Web
Pinkoi Mobile Web
 
openMIC barcamp 11.02.2010
openMIC barcamp 11.02.2010openMIC barcamp 11.02.2010
openMIC barcamp 11.02.2010
 
Making your site mobile-friendly - DevCSI Reading 21.07.2010
Making your site mobile-friendly - DevCSI Reading 21.07.2010Making your site mobile-friendly - DevCSI Reading 21.07.2010
Making your site mobile-friendly - DevCSI Reading 21.07.2010
 
[convergese] Adaptive Images in Responsive Web Design
[convergese] Adaptive Images in Responsive Web Design[convergese] Adaptive Images in Responsive Web Design
[convergese] Adaptive Images in Responsive Web Design
 
Bruce lawson-over-the-air
Bruce lawson-over-the-airBruce lawson-over-the-air
Bruce lawson-over-the-air
 
Html5
Html5Html5
Html5
 
Fake it 'til you make it
Fake it 'til you make itFake it 'til you make it
Fake it 'til you make it
 
Mobile Web Design Code
Mobile Web Design CodeMobile Web Design Code
Mobile Web Design Code
 
Web app
Web appWeb app
Web app
 
Mobile App Development
Mobile App DevelopmentMobile App Development
Mobile App Development
 
JavaONE 2012 Using Java with HTML5 and CSS3
JavaONE 2012 Using Java with HTML5 and CSS3JavaONE 2012 Using Java with HTML5 and CSS3
JavaONE 2012 Using Java with HTML5 and CSS3
 
Responsive design
Responsive designResponsive design
Responsive design
 
Responsive websites. Toolbox
Responsive websites. ToolboxResponsive websites. Toolbox
Responsive websites. Toolbox
 
Web app
Web appWeb app
Web app
 
Jsf2 html5-jazoon
Jsf2 html5-jazoonJsf2 html5-jazoon
Jsf2 html5-jazoon
 
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
 
Responsive Websites
Responsive WebsitesResponsive Websites
Responsive Websites
 

More from Adam Lu

Yui rocks
Yui rocksYui rocks
Yui rocks
Adam Lu
 
YUI介绍和使用YUI构建web应用
YUI介绍和使用YUI构建web应用YUI介绍和使用YUI构建web应用
YUI介绍和使用YUI构建web应用Adam Lu
 
一步一步开发Html5 mobile apps
一步一步开发Html5 mobile apps一步一步开发Html5 mobile apps
一步一步开发Html5 mobile appsAdam Lu
 
HTML5概览
HTML5概览HTML5概览
HTML5概览Adam Lu
 
Get started with YUI
Get started with YUIGet started with YUI
Get started with YUIAdam Lu
 
HTML5 on Mobile(For Designer)
HTML5 on Mobile(For Designer)HTML5 on Mobile(For Designer)
HTML5 on Mobile(For Designer)
Adam Lu
 
重新认识Html5
重新认识Html5重新认识Html5
重新认识Html5
Adam Lu
 
常用Js框架比较
常用Js框架比较常用Js框架比较
常用Js框架比较
Adam Lu
 
浏览器兼容性问题小结
浏览器兼容性问题小结浏览器兼容性问题小结
浏览器兼容性问题小结Adam Lu
 
小谈Javascript设计模式
小谈Javascript设计模式小谈Javascript设计模式
小谈Javascript设计模式
Adam Lu
 
从Adobe和qcof会议看前端开发
从Adobe和qcof会议看前端开发从Adobe和qcof会议看前端开发
从Adobe和qcof会议看前端开发Adam Lu
 
揭秘Html5和Css3
揭秘Html5和Css3揭秘Html5和Css3
揭秘Html5和Css3Adam Lu
 
Enhance Web Performance
Enhance Web PerformanceEnhance Web Performance
Enhance Web PerformanceAdam Lu
 

More from Adam Lu (13)

Yui rocks
Yui rocksYui rocks
Yui rocks
 
YUI介绍和使用YUI构建web应用
YUI介绍和使用YUI构建web应用YUI介绍和使用YUI构建web应用
YUI介绍和使用YUI构建web应用
 
一步一步开发Html5 mobile apps
一步一步开发Html5 mobile apps一步一步开发Html5 mobile apps
一步一步开发Html5 mobile apps
 
HTML5概览
HTML5概览HTML5概览
HTML5概览
 
Get started with YUI
Get started with YUIGet started with YUI
Get started with YUI
 
HTML5 on Mobile(For Designer)
HTML5 on Mobile(For Designer)HTML5 on Mobile(For Designer)
HTML5 on Mobile(For Designer)
 
重新认识Html5
重新认识Html5重新认识Html5
重新认识Html5
 
常用Js框架比较
常用Js框架比较常用Js框架比较
常用Js框架比较
 
浏览器兼容性问题小结
浏览器兼容性问题小结浏览器兼容性问题小结
浏览器兼容性问题小结
 
小谈Javascript设计模式
小谈Javascript设计模式小谈Javascript设计模式
小谈Javascript设计模式
 
从Adobe和qcof会议看前端开发
从Adobe和qcof会议看前端开发从Adobe和qcof会议看前端开发
从Adobe和qcof会议看前端开发
 
揭秘Html5和Css3
揭秘Html5和Css3揭秘Html5和Css3
揭秘Html5和Css3
 
Enhance Web Performance
Enhance Web PerformanceEnhance Web Performance
Enhance Web Performance
 

Recently uploaded

Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 

Recently uploaded (20)

Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 

Html5 on Mobile(For Developer)

  • 1. HTML5 on Mobile (For Developer) Adam Lu http://adamlu.com/
  • 2. Mobile is Growing • In January 2012, 8.49 percent of website hits/pageviews come from a handheld mobile device (StatCounter) • Mobile will be bigger than desktop internet in 5 years (Morgan Stanley) • 2.1 billion mobile devices will have HTML5 browsers by 2016 up from 109 million in 2010 (ABI Research)
  • 3. Mobile is Growing Source: Nielsen (January 2012)
  • 4. HTML5 is Great for Mobile • Do not need download to use Web App • One Code base, all popular devices • Tons of great HTML5 features are already supported on modern browsers
  • 5.
  • 6. Web App vsNative App Web App Native App Comparation Just enter the URL Must be deployed or Installation/updates downloaded Access to web analytics. Apple Store, Android Monetization Rate,SaaS based revenue Market, Rating Progressive Enhancement Follow the standards End User Experience GeoLocation, Offline camera, gyroscope, Access to hardware sensors Storage, Canvas Graphics, microphone, compass, Audio, Video, accelerometer, GPS Camera(Android3.1+) HTML5, CSS3, Javascript, UI Object-C, Java, C++, J2EE, Developer Experience Library .NET, Cocoa Touch Web Workers, Graphic Run directly on the metal, Performance acceleration, WebGL GPU Acceleration, Multi- Threading
  • 7. Mobile Users prefer browsers over apps (source: Adobe)
  • 9. What is HTML5 Forms, Communication, Canvas, Geolocation, Web Applications, Audio, WebGL, Microdata, Video, Workers, Files, Elements, Storage, Local Devices, User interaction, Parsing rules, …
  • 10. Build Mobile Web with HTML5 • Decide which platforms/browsers you will support -ms- Webkit on Mobile? -o- There is no webkit on mobile -moz- http://quirksmode.org/webkit.html -webkit-
  • 11. Build Mobile Web with HTML5 • HTML Markup <!DOCTYPE html> Semantic HTML: <html> <section> <head> <article> <meta charset="utf-8" /> <nav> <meta name="viewport" <aside> content="width=device-width, initial-scale=1, <header> maximum-scale=1, user-scalable=no"> <progress> <link rel="apple-touch-icon" <time> href="images/favicon.png" /> … </head> Basic Setting: <body> Set Viewport </body> Turn off user-scaling </html> Set favicon … http://www.w3.org/wiki/HTML/Elements
  • 12. Build Mobile Web with HTML5 • CSS Reset -webkit-text-size-adjust: none; -webkit-user-select: none; -webkit-touch-callout; -webkit-tap-highlight-color: transparent; audio, canvas, video { display: inline- block; } article, aside, details, figcaption, figure, footer, header, hgroup, nav, section { display: block; } input[type="search"]{ -webkit- appearance: none/textfield;}
  • 13. Build Mobile Web with HTML5 • Media Queries /*styles for 800px and up!*/ @media only screen and (min-width: 800px) { /* Styles */ } /* iPhone 4, Opera Mobile 11 and other high pixel ratio devices ----------- */ @media only screen and (-webkit-min-device-pixel- ratio: 1.5), only screen and (-o-min-device-pixel-ratio: 3/2), only screen and (min--moz-device-pixel-ratio: 1.5), only screen and (min-device-pixel-ratio: 1.5) { /* Styles */ }
  • 14. Build Mobile Web with HTML5 • CSS3 Effect <input id="p" type="search" autocorrect="off" autocomplete="off" autocapitalize="off" placeholder="Search" /> border-image: url() 0 24 stretch box-shadow: #9FA1A4 0 3px 4px 2px -webkit-border-radius: 5px; inset background: #FFAB23 -webkit- border-radius: 15px; gradient(linear,0% 0,0% background: -webkit-linear-gradient(); 100%,from(#FE6),to(#FFAB23)); box-sizing: border-box; http://mobile.twitter.com/session/new
  • 15. Build Mobile Web with HTML5 • Make Animation CSS3 Animation instead of JS Animation transition: left 1s ease-in-out; http://jsfiddle.net/adamlu/RE6dF/ YUI().use(‘transition’, function(){}); #box1, #box2{ -webkit-transition: all 2s ease-in-out; } #box1:hover + #box2 { -webkit-transform: rotate(360deg); left: 500px; http://jsfiddle.net/adamlu/t5Afm/ }​
  • 16. Build Mobile Web with HTML5 • Advanced Forms in Mobile <input type="number" pattern="[0-9]*" /> <input type="email” required /> <input type="url" /> <input type="tel" /> <input type="time" /> <input type="date" /> <input type="month" /> <input type="week" /> <input type="datetime" /> <input type="datetime-local" /> <input type="color" /> http://jquerymobile.com/demos/1.1.0- rc.1/docs/forms/textinputs/
  • 17. Build Mobile Web with HTML5 • Graphic Drawing - Canvas & SVG http://jsfiddle.net/adamlu/xFR4V/ <canvas id="a" width="300" height="225"></canvas> vara_canvas = document.getElementById("a"); vara_context = a_canvas.getContext("2d"); a_context.fillRect(50, 25, 150, 100); <svgxmlns="http://www.w3.org/2000/svg" version="1.1"> <circle cx="100" cy="50" r="40" stroke="black" stroke-width="2" fill="red" /> </svg> http://jsfiddle.net/adamlu/W67j8/ http://www.limejs.com/static/roundball/index.html
  • 18. Build Mobile Web with HTML5 • Media Support <video poster="" src="" width="2" height="1" x-webkit- airplay="allow"></video> <audio controls preload="auto" autobuffer> <source src="elvis.mp3" /> <source src="elvis.ogg" /> </audio>
  • 19. Build Mobile Web with HTML5 • Geolocation API Position Object navigator.geolocation.getCurrentPosition(succe ss, failure, options); PERMISSION_DENIED (1) POSITION_UNAVAILABLE (2) TIMEOUT (3) UNKNOWN_ERROR (0)
  • 20. Build Mobile Web with HTML5 • Javascript Events window.addEventListener("touchstart", function(e){ //e.touches; }, false); window.addEventListener("orientationchange", function(e){ //window.orientation(0 is portrait, 90 and -90 are landscape) }, false); window.addEventListener("deviceorientation", function(e){ //e.alpha //e.beta //e.gamma }, false); window.addEventListener("devicemotion", function(e){ //e.acceleration.x/y/z //e.accelerationIncludingGravity.x/y/z }, false); http://www.html5rocks.com/en/tutorials/device/orientation/
  • 21. Build Mobile Web with HTML5 • Device Support window.devicePixelRatio HTML Media Capture: navigator.connection(Android2.2+) <input type="file" accept="image/*" // contents of navigator.connection capture="camera" /> object <device type="media"></device> { "type": "3", <video autoplay></video> "UNKNOWN": "0", navigator.getUserMedia({video: true, "ETHERNET": "1", audio: true}, function(stream) { "WIFI": "2", var video = "CELL_2G": "3", document.querySelector('video'); "CELL_3G": "4" video.src = stream; } }, errorCallback); http://dev.w3.org/2011/webrtc/editor/getusermedia.html
  • 22. Build Mobile Web with HTML5 • User Interaction  Drag and Drop  HTML Editing  Session History window.history.pushState(data, title, url);//Add one history state into browser history and update the URL in the browser window. window.history.replaceState(state, title, url);//Modify the current history entry instead of creating a new one. window.onpopstate = function(e){e.state;};//A popstate event is dispatched to the window every time the active history entry changes. http://html5demos.com/history
  • 23. Build Mobile Web with HTML5 • Performance Offline Web Application Cache: <html manifest="/cache.manifest"> AddType text/cache-manifest .manifest CACHE MANIFEST NETWORK/CACHE/FALLBACK: LocalStorage/SessionStorage: varfoo = localStorage.getItem("bar"); localStorage.setItem("bar", foo); window.addEventListener("storage", handle_storage, false); Web Workers: var worker = new Worker('doWork.js'); worker.addEventListener('message', function(e) { console.log('Worker said: ', e.data); }, false); worker.postMessage('Hello World'); // Send data to our worker.
  • 24. Build Mobile Web with HTML5 • Communication  Cross-document messaging  Server-Sent Events(XHR2)  Web Sockets conn = new WebSocket('ws://node.remysharp.com:8001'); conn.onopen= function () {}; conn.onmessage= function (event) { // console.log(event.data); }; conn.onclose= function (event) { state.className = 'fail'; state.innerHTML = 'Socket closed'; }; http://html5demos.com/web-socket
  • 25. Build Mobile Web with HTML5 • Make Web App Full screen mode: <meta name="apple-mobile-web-app-capable" content="yes" /> Native Look: text-shadow box-shadow multi backgrounds border-image border-radius rgba color gradient transform transition Mobile Behavior: position: fixed; overflow: scroll; touch/gesture/orientationchange event Offline: AppCache LocalStorage http://adamlu.com/iEye/
  • 26. Mobile Web App Strategy • Evaluate your requirement • Decide what app you’ll do • A hybrid app maybe a good approach (Web App  Native App) • Mobile-First Responsive Design • Progressive Enhancement • Lighter is better
  • 27. Frameworks • Boilerplate http://html5boilerplate.com/mobile • Packaging frameworks  http://phonegap.com/  http://www.appmobi.com/ • Web application frameworks  http://jquerymobile.com/  http://yuilibrary.com/  http://sproutcore.com/  http://www.sencha.com/  http://zeptojs.com/ • HTML5 Game frameworks  http://www.limejs.com/  http://craftyjs.com/  http://impactjs.com/
  • 28. Tools • Debugging  WEINRE  WebKit Remote Debugging • Emulators & Simulators  Mobile Emulators and Simulators  Android Emulator  iOS Simulator • Performance  Mobile PerfBookmarklet  http://www.blaze.io/mobile/
  • 29. Compatibility • http://haz.io/ • http://caniuse.com/ • http://css3test.com/ • http://css3generator.com/ • http://css3info.com/ • http://html5test.com/ • http://css3please.com/ • http://mobilehtml5.org/ • http://quirksmode.org/m/
  • 30. Inspiration • http://mobile-patterns.com/ - Mobile UI Patterns • http://pttrns.com- Another gallery of Mobile UI • http://mobileawesomeness.com- the best in mobile web design and developer news.
  • 31. Resources • http://diveintohtml5.info/ • http://www.html5rocks.com/ • http://html5demos.com/ • http://www.mobilehtml5.com/ • http://www.w3.org/TR/html5/ • http://gs.statcounter.com/
  • 32. HTML5 is the future of Mobile!

Editor's Notes

  1. Develop in HTML5 for mobile devices namely deploy roughly the same code based on all HTML5-ready phones