SlideShare a Scribd company logo
1 of 84
Download to read offline
Web Anywhere
Mobile Optimisation With HTML5, CSS3, JavaScript




Bruce Lawson / SxSW/ 12 March 2011
introducinghtml5.com
Opera – one browser on many devices
"Our goal is to take the one true Web and
make it available to people on their terms."
                Jon S. von Tetzchner, Opera Co-founder

   "All I ask is access to the full Web, for everyone, everywhere.
                        And some more beer."
                                 Me
Most-popular mobile browsers (Opera=red)
China
  “The proportion of [people]
  accessing the Internet by mobile
  increased enormously from 39.5%
  in late 2008 to 46% in June 2009,
  while the proportion of using
  desktops and laptops decreased”.
  (close to 150 million people).
  Statistical Report on Internet Development in China,
  p25-26, July 2009, www.ccnic.cn
USA - www.opera.com/smw
Top 10 sites (unique users)   Top 10 handsets, Jan 2011
1. google.com                 1. Apple iPhone
2. facebook.com               2. LG VM265 “Rumor2”
3. youtube.com                3. BlackBerry 8520 “Curve”
4. wikipedia.org              4. BlackBerry 9700 “Bold”
5. yahoo.com                  5. LG VM510 “Rumor Touch”
6. my.opera.com               6. BlackBerry 8330 “Curve”
7. accuweather.com            7. BlackBerry 8900 “Curve”
8. twitter.com                8. BlackBerry 8530 “Curve”
9. espn.go.com                9. Samsung SPH-M810 “Instinct S30”
10.myspace.com                10.BlackBerry 9630 “Tour”
UK
Top 10 sites         Top handsets, January 2011
1. google.com        1. Apple iPhone
2. facebook.com      2. Nokia C3
3. bbc.co.uk         3. BlackBerry 8520 “Curve”
4. youtube.com       4. Nokia 2330c
5. wikipedia.org     5. BlackBerry 9700 “Bold”
6. live.com          6. Nokia 6700c
7. my.opera.com      7. Nokia 2730c
8. bing.com          8. BlackBerry 8900 “Curve”
9. mobile2day.com    9. Nokia 6300
10.newsnow.net       10.Nokia 6303c
Burma
Top 10 site             Top handsets
1. google.com            1. Apple iPhone
2. facebook.com          2. Nokia 5730s
3. bbc.co.uk             3. Nokia 5800d
4. my.opera.com          4. Sony Ericsson W800
5. nytimes.com           5. Nokia X3
6. espn.go.com           6. Nokia X6
7. cnnmobile.com         7. Sony Ericsson U5i
8. getjar.com            8. Nokia C3
9. topshareware.com      9. BlackBerry 9700 “Bold”
10.zedge.net             10.Nokia N8
Menu

Philosophy
3 Methodologies
Optimisation tips
and tricks
Future
Mobile Web philosophy
Three methodologies
1. Special mobile site
2. Do nothing at all
3. Optimise for mobile
1. Special mobile site
2. Do nothing at all
3. Optimise for mobile
refactored for small screen,
not dumbed down for mobile
offer users choice:
desktop or mobile?
beware browser sniffing
     photo: http://www.flickr.com/photos/timdorr/2096272747/
1. Special mobile site
2. Do nothing at all
3. Optimise for mobile
not WAP or text anymore...
mobile browsers
know how to deal with the Web
JavaScript touch events
addEventListener('touchstart'..)
 addEventListener('touchmove'..)
CSS 3
font control, text and box shadows,
 rounded corners, basic animations
-moz-transition: all 0.5s ease-in-out;
-ms-transition: all 0.5s ease-in-out;
-o-transition: all 0.5s ease-in-out;
-webkit-transition: all 0.5s ease-in-out;

transition: all 0.5s ease-in-out;
HTML5
<!DOCTYPE html>
“...extending the language to better support Web
applications, since that is one of the directions the Web is
going in and is one of the areas least well served by HTML
so far. ”

Ian Hickson, Editor of HTML5
http://lists.w3.org/Archives/Public/public-html/2009Jan/0215.html
<canvas>
canvas = “scriptable images”
<svg> or <canvas>?
Scalable Vector Graphics:
●
  Supported in 4 modern desktop browsers, and IE9
●
  Not supported in native Android browser, fine in Opera Mobile/
Android
●
  Vector graphics, therefore infinitely scalable
●
  XML so text-based - can be made accessible
●
  Keeps a DOM
●
    Can author with Adobe Illustrator or Inkscape
geolocation
find out your location via JavaScript
navigator.geolocation.getCurrentPosition(success, error);

function success(position) {
   /* where's Waldo? */
   var lat = position.coords.latitude;
   var long = position.coords.longitude;
   ...
}
Use for progressive
   enhancement
offline support
HTML5 forms
<input type=email>
 <input required>
 <input type=url>
detect if a browsers goes offline
window.addEventListener('online', function(){ … }, true);
window.addEventListener('offline', function(){ … }, true);
storage
localStorage/sessionStorage
like cookies...
document.cookie = 'key=value; expires=Thu, 15 Feb 2010
23:59:59 UTC; path=/'
…

/* convoluted string operations go here … */
localStorage/sessionStorage
like cookies...on steroids!
localStorage.setItem(key, value);
localStorage.getItem(key);
localStorage.clear();
localStorage.key = value;
if (localStorage.key == '…') { … }
…
application cache
cache UI/resource files for offline use
<html manifest=”blah.manifest”>

CACHE MANIFEST
# send this with correct text/cache-manifest MIME
images/sprites.png
scripts/common.js
scripts/jquery.js
styles/global.css
Server-sent Events
   Web Sockets
1. Special mobile site
2. Do nothing at all
3. Optimise for mobile
“One Web means making, as far as is reasonable, the
same information and services available to users
irrespective of the device they are using. However, it does
not mean that exactly the same information is available in
exactly the same representation across all devices.”
W3C Mobile Web Best Practices http://www.w3.org/TR/mobile-bp/#OneWeb
“responsive” design with CSS Media Queries

Querying device capabilites (width, height,
orientation, color, resolution, aspect ratio) not
browser sniffing
CSS 3 Media Queries:

@media screen and
       (max-width: 480px) {

    // insert CSS rules here

}
http://www.w3.org/TR/css3-mediaqueries/
http://mediaqueri.es
http://mediaqueri.es
http://mediaqueri.es
http://mediaqueri.es
Viewport metatag
physical vs virtual pixels
viewport meta
<meta name="viewport"
content="width=device-width">

<meta name="viewport"
content="width=320, initial-
scale=2.3,user-scalable=no">
http://developer.apple.com/safari/library/documentation/AppleApplications/Reference/SafariWebContent/UsingtheViewport/UsingtheViewport.html
<meta name="viewport" content="width=550">
If you're using Media Queries:

    <meta name="viewport"
content="width=device-width">

     If you have an explicit width:

    <meta name="viewport"
     content="width=550">
Tips 'n' tricks
HTML tips:

● Don't use <table>s for layout (dur)
●
  Give dimensions of images in HTML:
 <img height=x width=y src=foo.png
alt="blah">
●
    Consider <a href="tel:xxx"> for phone numbers
Code accessibly:

Lots of similarities with accessibility techniques:
Relationship between Mobile Web Best Practices
(MWBP) and Web Content Accessibility Guidelines
(WCAG)

           http://www.w3.org/TR/mwbp-wcag/
Minimise HTTP requests:

● Combine JS into one file. Same with CSS.
● Use CSS sprites to combine decorative images

● Consider SVG or <canvas> for images
CSS optimisation:

●
    ems instead of px for fonts
●
  Fluid layouts: remember motion sensors
●
  background-size / SVG background images
●
  Turn off fancy shadows, transitions etc with Media Queries
CSS sprites
#panel1b a:hover {
    background: transparent url(test-3.jpg)
    0 -200px no-repeat;}


  #panel2b a:hover {
    background: transparent url(test-3.jpg)
    -96px -200px no-repeat;}

               www.alistapart.com/articles/sprites/
data:image/x-icon,
                                %00%00%01%00%02%00%10%10%00%0
                                0%00%00%00%00h

Data URLs
                                %05%00%00%26%00%00%00%20%20%0
                                0%00%00%00%00%00%A8%08%00%00%
                                8%05%00%00(%00%00%00%10%00%00%00%20%00%00%00%01%00%08%00%00%00%0
                                0%00%40%01%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00
                                %00%00%00%00%FF%FF%FF%00u%7D%8C%00%B1%BF%CF%00%3D%3FG%00%D0%DF
                                %F3%00%9E%9F%A1%00%1A%1E%26%00Z%60g%00%D6%D8%D1%00%EC%EC%EB
                                %00%B2%B2%AD%00%88%8D%9E%00rpt%00KNZ%00%2C.%3E%00%C2%C2%BC
                                %00%C6%C9%D8%00%06%09%14%00%A9%AD%C1%00%9A%9E
                                %B6%00%86%88%87%00%7C%80z%00%CF%D4%E3%00%CB%CE
                                %C7%00%E2%E2%E1%00%11%14%1C%00%E3%E8%F8%00dht%00(.%2F%00%A5%AB
                                %B0%00%F6%F7%F6%00TTd%00ov
                                %80%00%91%93%96%00%B1%B6%C4%00%00%02%0C%00%8C%98%A1%00%C3%C4%CE
                                %00%BB%BE%D4%00%7F%81%8D%00lkm%00%D5%DA%E9%00%A6%A6%A7%00AHJ
                                %00TVZ%00%96%97%A0%007%3B%40%00%89%8E%93%00%DC%DC%DC%00ip%7B
                                %00%C6%C6%C5%00%FC%FF%F6%0015%3A%00%DE%E3%F2%00%85%87%97%00wt%7D
                                %00%5BV_%00xy%85%00%B7%BE%C9%0079H%00%A5%A9%BB%00acj%00%CA%CF%DF
                                %00%B5%B8%CF%00%CC%D3%EA%00%9E%A8%B1%00jmt%00%BF
                                %C7%D9%00%E9%E8%E6%00%85%89%90%00%8B%92%9A%00%7Bz%7D%00%D6%DF
                                %F6%00y%81%90%00(*4%00%CC%CC%CD%00%5B%5Bc%00%BF%C4%D3%00%BE%BF
                                %C0%00%F6%F5%F0%00chm%00%AB%B2%BE%00qr%7C%00%D4%D7%EE%00%C3%CA
                                %D3%00%BA%BF%CE%00%9E%A3%B4%00%8C%93%A4%00tt%82%00V%5Cg%00BCL
                                %00%00%00%07%00%F0%EF%ED%00%3BCJ%00GLW%00%D4%D4%D4%00%B4%BD




     http://software.hixie.ch/utilities/cgi/data/data
JavaScript tips:

●
  Put <script> elements as far down the source as
possible
●
  <script defer..>, <script async..>
●
  If it must be in the <head>, put it after CSS
●
  Feature detect – e.g. Modernizr
Web or Apps?
“…the browser run-time is perfect…you’re out of writing for Windows
Mobile, Android, S60, each of which require testing...we want to abstract
that.

All the cool innovation is happening inside the browser – you don’t
need to write to the native operating system anymore.”

Mobile Entertainment Market, June, 2009
W3C Widgets – application development filled
      with web standards goodness,
    using browser engine as platform
Anatomy of a widget
index.html, assets + config.xml,
        zipped and renamed .wgt
The future
W3C DAP
(Devices and Protocols Working Group)

              WAC
     (http://www.wacapps.net/)
Defining JavaScript APIs:

●
  Contacts (access address book)
●
  Calendar API
●
  Media Capture API (programmatic access to
camera/microphone)
● Messaging API (email/ SMS)

● accelerometer



                http://www.w3.org/2009/dap/
HTML5 <device>
Thank you Patrick Lauke
www.opera.com/developer
   bruce.lawson@opera.com
      twitter.com@brucel
Mobile-friendly: The mobile web optimization guide
dev.opera.com/articles/view/the-mobile-web-optimization-
                          guide/
      Opera Mini: web content authoring guidelines
  dev.opera.com/articles/view/opera-mini-web-content-
                 authoring-guidelines/

   Mobile Emulators & Simulators: The Ultimate Guide
           www.mobilexweb.com/emulators

       W3C Mobile Web Application Best Practices
              www.w3.org/TR/mwabp/

More Related Content

Viewers also liked

Does agile mean having even less time for testing?!
Does agile mean having even less time for testing?!Does agile mean having even less time for testing?!
Does agile mean having even less time for testing?!Dr. Alexander Schwartz
 
Bruce Lawson: Progressive Web Apps: the future of Apps
Bruce Lawson: Progressive Web Apps: the future of AppsBruce Lawson: Progressive Web Apps: the future of Apps
Bruce Lawson: Progressive Web Apps: the future of Appsbrucelawson
 
Being Agile and Seeing Big Picture
Being Agile and Seeing Big PictureBeing Agile and Seeing Big Picture
Being Agile and Seeing Big PictureAlex Leonov
 
Consumer Driven Contracts (DDD Perth 2016)
Consumer Driven Contracts (DDD Perth 2016)Consumer Driven Contracts (DDD Perth 2016)
Consumer Driven Contracts (DDD Perth 2016)Rob Crowley
 
Listening through Customer Insights
Listening through Customer InsightsListening through Customer Insights
Listening through Customer InsightsDelvinia
 
Progressive Downloads and Rendering
Progressive Downloads and RenderingProgressive Downloads and Rendering
Progressive Downloads and RenderingStoyan Stefanov
 
JavaScript is everywhere
JavaScript is everywhereJavaScript is everywhere
JavaScript is everywhereStoyan Stefanov
 
5 Mistakes of Massive CSS
5 Mistakes of Massive CSS5 Mistakes of Massive CSS
5 Mistakes of Massive CSSNicole Sullivan
 
BizOps and you
BizOps and youBizOps and you
BizOps and youLeon Fayer
 
Building a Progressive Web App
Building a  Progressive Web AppBuilding a  Progressive Web App
Building a Progressive Web AppIdo Green
 
JavaScript for PHP developers
JavaScript for PHP developersJavaScript for PHP developers
JavaScript for PHP developersStoyan Stefanov
 
Let's build an Airport – How to estimate large scale projects
Let's build an Airport – How to estimate large scale projectsLet's build an Airport – How to estimate large scale projects
Let's build an Airport – How to estimate large scale projects☕ 🥧 🚲 Martin Gude
 
Big-tent UX (UX Camp West 2016)
Big-tent UX (UX Camp West 2016)Big-tent UX (UX Camp West 2016)
Big-tent UX (UX Camp West 2016)Peter Boersma
 

Viewers also liked (15)

Does agile mean having even less time for testing?!
Does agile mean having even less time for testing?!Does agile mean having even less time for testing?!
Does agile mean having even less time for testing?!
 
Bruce Lawson: Progressive Web Apps: the future of Apps
Bruce Lawson: Progressive Web Apps: the future of AppsBruce Lawson: Progressive Web Apps: the future of Apps
Bruce Lawson: Progressive Web Apps: the future of Apps
 
Being Agile and Seeing Big Picture
Being Agile and Seeing Big PictureBeing Agile and Seeing Big Picture
Being Agile and Seeing Big Picture
 
Consumer Driven Contracts (DDD Perth 2016)
Consumer Driven Contracts (DDD Perth 2016)Consumer Driven Contracts (DDD Perth 2016)
Consumer Driven Contracts (DDD Perth 2016)
 
Listening through Customer Insights
Listening through Customer InsightsListening through Customer Insights
Listening through Customer Insights
 
Origin and history of convolution
Origin and history of convolutionOrigin and history of convolution
Origin and history of convolution
 
Progressive Downloads and Rendering
Progressive Downloads and RenderingProgressive Downloads and Rendering
Progressive Downloads and Rendering
 
JavaScript is everywhere
JavaScript is everywhereJavaScript is everywhere
JavaScript is everywhere
 
5 Mistakes of Massive CSS
5 Mistakes of Massive CSS5 Mistakes of Massive CSS
5 Mistakes of Massive CSS
 
BizOps and you
BizOps and youBizOps and you
BizOps and you
 
YSlow 2.0
YSlow 2.0YSlow 2.0
YSlow 2.0
 
Building a Progressive Web App
Building a  Progressive Web AppBuilding a  Progressive Web App
Building a Progressive Web App
 
JavaScript for PHP developers
JavaScript for PHP developersJavaScript for PHP developers
JavaScript for PHP developers
 
Let's build an Airport – How to estimate large scale projects
Let's build an Airport – How to estimate large scale projectsLet's build an Airport – How to estimate large scale projects
Let's build an Airport – How to estimate large scale projects
 
Big-tent UX (UX Camp West 2016)
Big-tent UX (UX Camp West 2016)Big-tent UX (UX Camp West 2016)
Big-tent UX (UX Camp West 2016)
 

Similar to Web Anywhere: Mobile Optimisation With HTML5, CSS3, JavaScript

Stefan Judis "Did we(b development) lose the right direction?"
Stefan Judis "Did we(b development) lose the right direction?"Stefan Judis "Did we(b development) lose the right direction?"
Stefan Judis "Did we(b development) lose the right direction?"Fwdays
 
HTML5: Markup Evolved
HTML5: Markup EvolvedHTML5: Markup Evolved
HTML5: Markup EvolvedBilly Hylton
 
Responsive UX - One size fits all @BigDesign conference #BigD12
Responsive UX - One size fits all   @BigDesign conference #BigD12Responsive UX - One size fits all   @BigDesign conference #BigD12
Responsive UX - One size fits all @BigDesign conference #BigD12touchtitans
 
Web Performance Optimierung - DWX13
Web Performance Optimierung - DWX13Web Performance Optimierung - DWX13
Web Performance Optimierung - DWX13Walter Ebert
 
Mobilism 2011: How to put the mobile in the mobile web
Mobilism 2011: How to put the mobile in the mobile webMobilism 2011: How to put the mobile in the mobile web
Mobilism 2011: How to put the mobile in the mobile webJenifer Hanen
 
Responsive Web Design: A Deep-Dive Crash Course
Responsive Web Design: A Deep-Dive Crash CourseResponsive Web Design: A Deep-Dive Crash Course
Responsive Web Design: A Deep-Dive Crash CourseMatt Smith
 
Why HTML5 is getting on my nerves…
Why HTML5 is getting on my nerves…Why HTML5 is getting on my nerves…
Why HTML5 is getting on my nerves…Avenga Germany GmbH
 
[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
 
Web Development for Mobile: GTUG Talk at Google
Web Development for Mobile: GTUG Talk at GoogleWeb Development for Mobile: GTUG Talk at Google
Web Development for Mobile: GTUG Talk at GoogleEstelle Weyl
 
Html5 on Mobile(For Developer)
Html5 on Mobile(For Developer)Html5 on Mobile(For Developer)
Html5 on Mobile(For Developer)Adam Lu
 
HTML5, the open web, and what it means for you -Tech4Africa
HTML5, the open web, and what it means for you -Tech4AfricaHTML5, the open web, and what it means for you -Tech4Africa
HTML5, the open web, and what it means for you -Tech4AfricaRobert Nyman
 
The State of Web Development
The State of Web DevelopmentThe State of Web Development
The State of Web DevelopmentSatoshi Kikuchi
 
Web 4.0 (or The importance of R&D)
Web 4.0 (or The importance of R&D)Web 4.0 (or The importance of R&D)
Web 4.0 (or The importance of R&D)Russell Cavell
 
Widget Summit 2008
Widget Summit 2008Widget Summit 2008
Widget Summit 2008Volkan Unsal
 
[Azure Council Experts (ACE) 第34回定例会] Microsoft Azureアップデート情報 (2019/02/15-201...
[Azure Council Experts (ACE) 第34回定例会] Microsoft Azureアップデート情報 (2019/02/15-201...[Azure Council Experts (ACE) 第34回定例会] Microsoft Azureアップデート情報 (2019/02/15-201...
[Azure Council Experts (ACE) 第34回定例会] Microsoft Azureアップデート情報 (2019/02/15-201...Naoki (Neo) SATO
 
The Mobile Question: Lessons in Design and Strategy for Your Mobile Experience
The Mobile Question: Lessons in Design and Strategy for Your Mobile ExperienceThe Mobile Question: Lessons in Design and Strategy for Your Mobile Experience
The Mobile Question: Lessons in Design and Strategy for Your Mobile ExperienceJeremy Johnson
 

Similar to Web Anywhere: Mobile Optimisation With HTML5, CSS3, JavaScript (20)

Stefan Judis "Did we(b development) lose the right direction?"
Stefan Judis "Did we(b development) lose the right direction?"Stefan Judis "Did we(b development) lose the right direction?"
Stefan Judis "Did we(b development) lose the right direction?"
 
HTML5: Markup Evolved
HTML5: Markup EvolvedHTML5: Markup Evolved
HTML5: Markup Evolved
 
Responsive UX - One size fits all @BigDesign conference #BigD12
Responsive UX - One size fits all   @BigDesign conference #BigD12Responsive UX - One size fits all   @BigDesign conference #BigD12
Responsive UX - One size fits all @BigDesign conference #BigD12
 
Web Performance Optimierung - DWX13
Web Performance Optimierung - DWX13Web Performance Optimierung - DWX13
Web Performance Optimierung - DWX13
 
Bartoz Goralewicz - Advanced Search Summit Napa 2019
Bartoz Goralewicz - Advanced Search Summit Napa 2019Bartoz Goralewicz - Advanced Search Summit Napa 2019
Bartoz Goralewicz - Advanced Search Summit Napa 2019
 
Mobilism 2011: How to put the mobile in the mobile web
Mobilism 2011: How to put the mobile in the mobile webMobilism 2011: How to put the mobile in the mobile web
Mobilism 2011: How to put the mobile in the mobile web
 
Mobile for web developers
Mobile for web developersMobile for web developers
Mobile for web developers
 
Responsive Web Design: A Deep-Dive Crash Course
Responsive Web Design: A Deep-Dive Crash CourseResponsive Web Design: A Deep-Dive Crash Course
Responsive Web Design: A Deep-Dive Crash Course
 
Why HTML5 is getting on my nerves…
Why HTML5 is getting on my nerves…Why HTML5 is getting on my nerves…
Why HTML5 is getting on my nerves…
 
Flourish2011
Flourish2011Flourish2011
Flourish2011
 
[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
 
Web Development for Mobile: GTUG Talk at Google
Web Development for Mobile: GTUG Talk at GoogleWeb Development for Mobile: GTUG Talk at Google
Web Development for Mobile: GTUG Talk at Google
 
Html5 on Mobile(For Developer)
Html5 on Mobile(For Developer)Html5 on Mobile(For Developer)
Html5 on Mobile(For Developer)
 
Responsive design
Responsive designResponsive design
Responsive design
 
HTML5, the open web, and what it means for you -Tech4Africa
HTML5, the open web, and what it means for you -Tech4AfricaHTML5, the open web, and what it means for you -Tech4Africa
HTML5, the open web, and what it means for you -Tech4Africa
 
The State of Web Development
The State of Web DevelopmentThe State of Web Development
The State of Web Development
 
Web 4.0 (or The importance of R&D)
Web 4.0 (or The importance of R&D)Web 4.0 (or The importance of R&D)
Web 4.0 (or The importance of R&D)
 
Widget Summit 2008
Widget Summit 2008Widget Summit 2008
Widget Summit 2008
 
[Azure Council Experts (ACE) 第34回定例会] Microsoft Azureアップデート情報 (2019/02/15-201...
[Azure Council Experts (ACE) 第34回定例会] Microsoft Azureアップデート情報 (2019/02/15-201...[Azure Council Experts (ACE) 第34回定例会] Microsoft Azureアップデート情報 (2019/02/15-201...
[Azure Council Experts (ACE) 第34回定例会] Microsoft Azureアップデート情報 (2019/02/15-201...
 
The Mobile Question: Lessons in Design and Strategy for Your Mobile Experience
The Mobile Question: Lessons in Design and Strategy for Your Mobile ExperienceThe Mobile Question: Lessons in Design and Strategy for Your Mobile Experience
The Mobile Question: Lessons in Design and Strategy for Your Mobile Experience
 

More from brucelawson

HTML5 multimedia - where we are, where we're going
HTML5 multimedia - where we are, where we're goingHTML5 multimedia - where we are, where we're going
HTML5 multimedia - where we are, where we're goingbrucelawson
 
You too can be a bedwetting antfucker: Bruce Lawson, Opera, Fronteers 2011
You too can be a bedwetting antfucker: Bruce Lawson, Opera, Fronteers 2011You too can be a bedwetting antfucker: Bruce Lawson, Opera, Fronteers 2011
You too can be a bedwetting antfucker: Bruce Lawson, Opera, Fronteers 2011brucelawson
 
HTML5 and Accessibility sitting in a tree
HTML5 and Accessibility sitting in a treeHTML5 and Accessibility sitting in a tree
HTML5 and Accessibility sitting in a treebrucelawson
 
HTML5 Multimedia Accessibility
HTML5 Multimedia AccessibilityHTML5 Multimedia Accessibility
HTML5 Multimedia Accessibilitybrucelawson
 
HTML5 Multimedia: where we are, where we're going
HTML5 Multimedia: where we are, where we're goingHTML5 Multimedia: where we are, where we're going
HTML5 Multimedia: where we are, where we're goingbrucelawson
 
Why Open Web Standards are cool and will save the world. Or the Web, at least.
Why Open Web Standards are cool and will save the world. Or the Web, at least.Why Open Web Standards are cool and will save the world. Or the Web, at least.
Why Open Web Standards are cool and will save the world. Or the Web, at least.brucelawson
 
W3C Widgets: Apps made with Web Standards
W3C Widgets: Apps made with Web StandardsW3C Widgets: Apps made with Web Standards
W3C Widgets: Apps made with Web Standardsbrucelawson
 
Bruce lawson-html5-aria-japan
Bruce lawson-html5-aria-japanBruce lawson-html5-aria-japan
Bruce lawson-html5-aria-japanbrucelawson
 
Html5 oslo-code-camp
Html5 oslo-code-campHtml5 oslo-code-camp
Html5 oslo-code-campbrucelawson
 
Bruce lawson Stockholm Geek Meet
Bruce lawson Stockholm Geek MeetBruce lawson Stockholm Geek Meet
Bruce lawson Stockholm Geek Meetbrucelawson
 
Bruce lawson-over-the-air
Bruce lawson-over-the-airBruce lawson-over-the-air
Bruce lawson-over-the-airbrucelawson
 
Bruce Lawson, Web Development 2.0, SparkUp! Poznan Poland
Bruce Lawson, Web Development 2.0, SparkUp! Poznan PolandBruce Lawson, Web Development 2.0, SparkUp! Poznan Poland
Bruce Lawson, Web Development 2.0, SparkUp! Poznan Polandbrucelawson
 
Bruce Lawson HTML5 South By SouthWest presentation
Bruce Lawson HTML5 South By SouthWest presentationBruce Lawson HTML5 South By SouthWest presentation
Bruce Lawson HTML5 South By SouthWest presentationbrucelawson
 
Practical Tips for Mobile Widget development
Practical Tips for Mobile Widget developmentPractical Tips for Mobile Widget development
Practical Tips for Mobile Widget developmentbrucelawson
 
Bruce Lawson Opera Indonesia
Bruce Lawson Opera IndonesiaBruce Lawson Opera Indonesia
Bruce Lawson Opera Indonesiabrucelawson
 
Standards.next: HTML - Are you mything the point?
Standards.next: HTML - Are you mything the point?Standards.next: HTML - Are you mything the point?
Standards.next: HTML - Are you mything the point?brucelawson
 

More from brucelawson (18)

HTML5 multimedia - where we are, where we're going
HTML5 multimedia - where we are, where we're goingHTML5 multimedia - where we are, where we're going
HTML5 multimedia - where we are, where we're going
 
You too can be a bedwetting antfucker: Bruce Lawson, Opera, Fronteers 2011
You too can be a bedwetting antfucker: Bruce Lawson, Opera, Fronteers 2011You too can be a bedwetting antfucker: Bruce Lawson, Opera, Fronteers 2011
You too can be a bedwetting antfucker: Bruce Lawson, Opera, Fronteers 2011
 
HTML5 and Accessibility sitting in a tree
HTML5 and Accessibility sitting in a treeHTML5 and Accessibility sitting in a tree
HTML5 and Accessibility sitting in a tree
 
HTML5 Multimedia Accessibility
HTML5 Multimedia AccessibilityHTML5 Multimedia Accessibility
HTML5 Multimedia Accessibility
 
HTML5 Multimedia: where we are, where we're going
HTML5 Multimedia: where we are, where we're goingHTML5 Multimedia: where we are, where we're going
HTML5 Multimedia: where we are, where we're going
 
Why Open Web Standards are cool and will save the world. Or the Web, at least.
Why Open Web Standards are cool and will save the world. Or the Web, at least.Why Open Web Standards are cool and will save the world. Or the Web, at least.
Why Open Web Standards are cool and will save the world. Or the Web, at least.
 
W3C Widgets: Apps made with Web Standards
W3C Widgets: Apps made with Web StandardsW3C Widgets: Apps made with Web Standards
W3C Widgets: Apps made with Web Standards
 
Bruce lawson-html5-aria-japan
Bruce lawson-html5-aria-japanBruce lawson-html5-aria-japan
Bruce lawson-html5-aria-japan
 
HTML5 and CSS 3
HTML5 and CSS 3HTML5 and CSS 3
HTML5 and CSS 3
 
Html5 oslo-code-camp
Html5 oslo-code-campHtml5 oslo-code-camp
Html5 oslo-code-camp
 
Disruptive code
Disruptive codeDisruptive code
Disruptive code
 
Bruce lawson Stockholm Geek Meet
Bruce lawson Stockholm Geek MeetBruce lawson Stockholm Geek Meet
Bruce lawson Stockholm Geek Meet
 
Bruce lawson-over-the-air
Bruce lawson-over-the-airBruce lawson-over-the-air
Bruce lawson-over-the-air
 
Bruce Lawson, Web Development 2.0, SparkUp! Poznan Poland
Bruce Lawson, Web Development 2.0, SparkUp! Poznan PolandBruce Lawson, Web Development 2.0, SparkUp! Poznan Poland
Bruce Lawson, Web Development 2.0, SparkUp! Poznan Poland
 
Bruce Lawson HTML5 South By SouthWest presentation
Bruce Lawson HTML5 South By SouthWest presentationBruce Lawson HTML5 South By SouthWest presentation
Bruce Lawson HTML5 South By SouthWest presentation
 
Practical Tips for Mobile Widget development
Practical Tips for Mobile Widget developmentPractical Tips for Mobile Widget development
Practical Tips for Mobile Widget development
 
Bruce Lawson Opera Indonesia
Bruce Lawson Opera IndonesiaBruce Lawson Opera Indonesia
Bruce Lawson Opera Indonesia
 
Standards.next: HTML - Are you mything the point?
Standards.next: HTML - Are you mything the point?Standards.next: HTML - Are you mything the point?
Standards.next: HTML - Are you mything the point?
 

Web Anywhere: Mobile Optimisation With HTML5, CSS3, JavaScript

  • 1. Web Anywhere Mobile Optimisation With HTML5, CSS3, JavaScript Bruce Lawson / SxSW/ 12 March 2011
  • 3. Opera – one browser on many devices
  • 4. "Our goal is to take the one true Web and make it available to people on their terms." Jon S. von Tetzchner, Opera Co-founder "All I ask is access to the full Web, for everyone, everywhere. And some more beer." Me
  • 6.
  • 7. China “The proportion of [people] accessing the Internet by mobile increased enormously from 39.5% in late 2008 to 46% in June 2009, while the proportion of using desktops and laptops decreased”. (close to 150 million people). Statistical Report on Internet Development in China, p25-26, July 2009, www.ccnic.cn
  • 8. USA - www.opera.com/smw Top 10 sites (unique users) Top 10 handsets, Jan 2011 1. google.com 1. Apple iPhone 2. facebook.com 2. LG VM265 “Rumor2” 3. youtube.com 3. BlackBerry 8520 “Curve” 4. wikipedia.org 4. BlackBerry 9700 “Bold” 5. yahoo.com 5. LG VM510 “Rumor Touch” 6. my.opera.com 6. BlackBerry 8330 “Curve” 7. accuweather.com 7. BlackBerry 8900 “Curve” 8. twitter.com 8. BlackBerry 8530 “Curve” 9. espn.go.com 9. Samsung SPH-M810 “Instinct S30” 10.myspace.com 10.BlackBerry 9630 “Tour”
  • 9. UK Top 10 sites Top handsets, January 2011 1. google.com 1. Apple iPhone 2. facebook.com 2. Nokia C3 3. bbc.co.uk 3. BlackBerry 8520 “Curve” 4. youtube.com 4. Nokia 2330c 5. wikipedia.org 5. BlackBerry 9700 “Bold” 6. live.com 6. Nokia 6700c 7. my.opera.com 7. Nokia 2730c 8. bing.com 8. BlackBerry 8900 “Curve” 9. mobile2day.com 9. Nokia 6300 10.newsnow.net 10.Nokia 6303c
  • 10. Burma Top 10 site Top handsets 1. google.com 1. Apple iPhone 2. facebook.com 2. Nokia 5730s 3. bbc.co.uk 3. Nokia 5800d 4. my.opera.com 4. Sony Ericsson W800 5. nytimes.com 5. Nokia X3 6. espn.go.com 6. Nokia X6 7. cnnmobile.com 7. Sony Ericsson U5i 8. getjar.com 8. Nokia C3 9. topshareware.com 9. BlackBerry 9700 “Bold” 10.zedge.net 10.Nokia N8
  • 13.
  • 15. 1. Special mobile site 2. Do nothing at all 3. Optimise for mobile
  • 16. 1. Special mobile site 2. Do nothing at all 3. Optimise for mobile
  • 17. refactored for small screen, not dumbed down for mobile
  • 19. beware browser sniffing photo: http://www.flickr.com/photos/timdorr/2096272747/
  • 20.
  • 21. 1. Special mobile site 2. Do nothing at all 3. Optimise for mobile
  • 22. not WAP or text anymore...
  • 23. mobile browsers know how to deal with the Web
  • 25. CSS 3 font control, text and box shadows, rounded corners, basic animations
  • 26. -moz-transition: all 0.5s ease-in-out; -ms-transition: all 0.5s ease-in-out; -o-transition: all 0.5s ease-in-out; -webkit-transition: all 0.5s ease-in-out; transition: all 0.5s ease-in-out;
  • 28. “...extending the language to better support Web applications, since that is one of the directions the Web is going in and is one of the areas least well served by HTML so far. ” Ian Hickson, Editor of HTML5 http://lists.w3.org/Archives/Public/public-html/2009Jan/0215.html
  • 32. Scalable Vector Graphics: ● Supported in 4 modern desktop browsers, and IE9 ● Not supported in native Android browser, fine in Opera Mobile/ Android ● Vector graphics, therefore infinitely scalable ● XML so text-based - can be made accessible ● Keeps a DOM ● Can author with Adobe Illustrator or Inkscape
  • 34. find out your location via JavaScript navigator.geolocation.getCurrentPosition(success, error); function success(position) { /* where's Waldo? */ var lat = position.coords.latitude; var long = position.coords.longitude; ... }
  • 35. Use for progressive enhancement
  • 36.
  • 38. HTML5 forms <input type=email> <input required> <input type=url>
  • 39.
  • 40.
  • 41. detect if a browsers goes offline window.addEventListener('online', function(){ … }, true); window.addEventListener('offline', function(){ … }, true);
  • 43. localStorage/sessionStorage like cookies... document.cookie = 'key=value; expires=Thu, 15 Feb 2010 23:59:59 UTC; path=/' … /* convoluted string operations go here … */
  • 44. localStorage/sessionStorage like cookies...on steroids! localStorage.setItem(key, value); localStorage.getItem(key); localStorage.clear(); localStorage.key = value; if (localStorage.key == '…') { … } …
  • 46. cache UI/resource files for offline use <html manifest=”blah.manifest”> CACHE MANIFEST # send this with correct text/cache-manifest MIME images/sprites.png scripts/common.js scripts/jquery.js styles/global.css
  • 47. Server-sent Events Web Sockets
  • 48. 1. Special mobile site 2. Do nothing at all 3. Optimise for mobile
  • 49. “One Web means making, as far as is reasonable, the same information and services available to users irrespective of the device they are using. However, it does not mean that exactly the same information is available in exactly the same representation across all devices.” W3C Mobile Web Best Practices http://www.w3.org/TR/mobile-bp/#OneWeb
  • 50. “responsive” design with CSS Media Queries Querying device capabilites (width, height, orientation, color, resolution, aspect ratio) not browser sniffing
  • 51. CSS 3 Media Queries: @media screen and (max-width: 480px) { // insert CSS rules here } http://www.w3.org/TR/css3-mediaqueries/
  • 58.
  • 59. viewport meta <meta name="viewport" content="width=device-width"> <meta name="viewport" content="width=320, initial- scale=2.3,user-scalable=no"> http://developer.apple.com/safari/library/documentation/AppleApplications/Reference/SafariWebContent/UsingtheViewport/UsingtheViewport.html
  • 60.
  • 61.
  • 63. If you're using Media Queries: <meta name="viewport" content="width=device-width"> If you have an explicit width: <meta name="viewport" content="width=550">
  • 65. HTML tips: ● Don't use <table>s for layout (dur) ● Give dimensions of images in HTML: <img height=x width=y src=foo.png alt="blah"> ● Consider <a href="tel:xxx"> for phone numbers
  • 66. Code accessibly: Lots of similarities with accessibility techniques: Relationship between Mobile Web Best Practices (MWBP) and Web Content Accessibility Guidelines (WCAG) http://www.w3.org/TR/mwbp-wcag/
  • 67. Minimise HTTP requests: ● Combine JS into one file. Same with CSS. ● Use CSS sprites to combine decorative images ● Consider SVG or <canvas> for images
  • 68. CSS optimisation: ● ems instead of px for fonts ● Fluid layouts: remember motion sensors ● background-size / SVG background images ● Turn off fancy shadows, transitions etc with Media Queries
  • 69. CSS sprites #panel1b a:hover { background: transparent url(test-3.jpg) 0 -200px no-repeat;} #panel2b a:hover { background: transparent url(test-3.jpg) -96px -200px no-repeat;} www.alistapart.com/articles/sprites/
  • 70. data:image/x-icon, %00%00%01%00%02%00%10%10%00%0 0%00%00%00%00h Data URLs %05%00%00%26%00%00%00%20%20%0 0%00%00%00%00%00%A8%08%00%00% 8%05%00%00(%00%00%00%10%00%00%00%20%00%00%00%01%00%08%00%00%00%0 0%00%40%01%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00 %00%00%00%00%FF%FF%FF%00u%7D%8C%00%B1%BF%CF%00%3D%3FG%00%D0%DF %F3%00%9E%9F%A1%00%1A%1E%26%00Z%60g%00%D6%D8%D1%00%EC%EC%EB %00%B2%B2%AD%00%88%8D%9E%00rpt%00KNZ%00%2C.%3E%00%C2%C2%BC %00%C6%C9%D8%00%06%09%14%00%A9%AD%C1%00%9A%9E %B6%00%86%88%87%00%7C%80z%00%CF%D4%E3%00%CB%CE %C7%00%E2%E2%E1%00%11%14%1C%00%E3%E8%F8%00dht%00(.%2F%00%A5%AB %B0%00%F6%F7%F6%00TTd%00ov %80%00%91%93%96%00%B1%B6%C4%00%00%02%0C%00%8C%98%A1%00%C3%C4%CE %00%BB%BE%D4%00%7F%81%8D%00lkm%00%D5%DA%E9%00%A6%A6%A7%00AHJ %00TVZ%00%96%97%A0%007%3B%40%00%89%8E%93%00%DC%DC%DC%00ip%7B %00%C6%C6%C5%00%FC%FF%F6%0015%3A%00%DE%E3%F2%00%85%87%97%00wt%7D %00%5BV_%00xy%85%00%B7%BE%C9%0079H%00%A5%A9%BB%00acj%00%CA%CF%DF %00%B5%B8%CF%00%CC%D3%EA%00%9E%A8%B1%00jmt%00%BF %C7%D9%00%E9%E8%E6%00%85%89%90%00%8B%92%9A%00%7Bz%7D%00%D6%DF %F6%00y%81%90%00(*4%00%CC%CC%CD%00%5B%5Bc%00%BF%C4%D3%00%BE%BF %C0%00%F6%F5%F0%00chm%00%AB%B2%BE%00qr%7C%00%D4%D7%EE%00%C3%CA %D3%00%BA%BF%CE%00%9E%A3%B4%00%8C%93%A4%00tt%82%00V%5Cg%00BCL %00%00%00%07%00%F0%EF%ED%00%3BCJ%00GLW%00%D4%D4%D4%00%B4%BD http://software.hixie.ch/utilities/cgi/data/data
  • 71. JavaScript tips: ● Put <script> elements as far down the source as possible ● <script defer..>, <script async..> ● If it must be in the <head>, put it after CSS ● Feature detect – e.g. Modernizr
  • 72.
  • 74.
  • 75. “…the browser run-time is perfect…you’re out of writing for Windows Mobile, Android, S60, each of which require testing...we want to abstract that. All the cool innovation is happening inside the browser – you don’t need to write to the native operating system anymore.” Mobile Entertainment Market, June, 2009
  • 76. W3C Widgets – application development filled with web standards goodness, using browser engine as platform
  • 77. Anatomy of a widget index.html, assets + config.xml, zipped and renamed .wgt
  • 79. W3C DAP (Devices and Protocols Working Group) WAC (http://www.wacapps.net/)
  • 80. Defining JavaScript APIs: ● Contacts (access address book) ● Calendar API ● Media Capture API (programmatic access to camera/microphone) ● Messaging API (email/ SMS) ● accelerometer http://www.w3.org/2009/dap/
  • 82.
  • 83. Thank you Patrick Lauke www.opera.com/developer bruce.lawson@opera.com twitter.com@brucel
  • 84. Mobile-friendly: The mobile web optimization guide dev.opera.com/articles/view/the-mobile-web-optimization- guide/ Opera Mini: web content authoring guidelines dev.opera.com/articles/view/opera-mini-web-content- authoring-guidelines/ Mobile Emulators & Simulators: The Ultimate Guide www.mobilexweb.com/emulators W3C Mobile Web Application Best Practices www.w3.org/TR/mwabp/