JavaScript
      on
Mobile Devices
     Jens Arps
       uxebu
We open the mobile web.
http://www.flickr.com/photos/63629542@N00/435549194/




       JS on the desktop
http://www.flickr.com/photos/phily/263037865/




       JS on mobile?
Mobile Devices


• Smartphones
Mobile Devices


• Smartphones
• Featurephones
Mobile Devices

• Smartphones
• Featurephones
• Non phone handhelds
Mobile Devices

• Smartphones
• Featurephones
• Non phone handhelds
• TVs
Mobile Devices

• Smartphones
• Featurephones
• Non phone handhelds
• TVs
• Gaming Consoles
Mobile
Embedded Devices
• Smartphones
• Featurephones
• Non phone handhelds
• TVs
• Gaming Consoles
Browser Landscape

• WebKit
• Opera Mini / Mobile
• NetFront, Blackberry, IE Mobile
•…
Browser Landscape

                 WebKit rules!

For compatability charts, see @ppk‘s quirksmode:
     http://quirksmode.org/m/w3c_core.html
Browser Landscape

               Good news:
      1) iOS and Android devices use WebKits
      2) Most mobile WebKits are pretty good
3) 8 of the top 10 smartphones are iOS or Android
Performance
Performance
Again: My phone reads 1,000 entries from
         localStorage in 16.4ms.
Performance differs!
  Some DOM modifcation test‘s results:

      HTC Desire        0.8s
      Samsung Wave      2.1s
      iPhone 3.1       11.1s
      iPhone 2.2       14.3s
      IE Mobile 6       died
Performance differs!
  Some DOM modifcation test‘s results:

      HTC Desire        0.8s


         TES T!
      Samsung Wave
      iPhone 3.1
                        2.1s
                       11.1s
      iPhone 2.2       14.3s
      IE Mobile 6       died
WebApps
  (Yeah!)
WebApps? native?
Tools like Phonegap or Titanium can turn your
            WebApps to native apps.
iOS meta tags
http://developer.apple.com/safari/library/documentation/appleapplications/reference/safarihtmlref/articles/metatags.html




      - apple-mobile-web-app-capable
      - apple-mobile-web-app-status-bar-style
      - viewport
Pitfalls
  typeof(webkit) == “webkit“ // false


• 10+ WebKits out there
• iPhone‘s WebKit is great, Android
  1.5‘s is not

• JS is pretty similar, except for new
  features (localStorage, e.g.)

     (check: http://quirksmode.org/webkit.html)
Pitfalls
                caching is limited



• iOS 3.2 does not cache components
  larger than 25.6kb

• gzip does not count

   http://www.yuiblog.com/blog/2010/06/28/mobile-browser-cache-limits/
Pitfalls
        Android is not iOS!

• Android has keyboard navigation
• Only <a> elements receive focus
  using keys

• Android knows hover states
• Android doesn‘t trigger
  onorientationchange
Pitfalls
      click event != touch event


• click events are fired
• iPhone fires single click event
  300ms after the touch event

• learn and use touch events, they are
  powerful
Summary
All‘s good, really. Code on.
Thanks.

http://uxebu.com

     Jens Arps, uxebu

     arps@uxebu.com
 http://twitter.com/uxebu
http://twitter.com/jensarps
     http://jensarps.de

Js On Mobile Devices

Editor's Notes

  • #4 * Js on desktop is all the juicy power * webGL, canvas-video, JS flash container * big question is: -&gt;
  • #5 is that js on mobile devices?? lets find it out! -&gt; first, we need to define what mobile devices are:
  • #6 iphone, ipad, android phones
  • #7 phones that make it into the net somehow, like my old nokia
  • #8 the ogo, or the psp -&gt; but, there are also:
  • #9 yes, TV widgets! widget-capable tvs are already sold right now.
  • #10 Wii, PS3 all have internet browsers
  • #11 * so we need to speak of embedded devices instead (car dashboard) * but, we will focus on smartphones today -&gt; some good fragmentation! and the browsers?
  • #12 we have webkit (yeah!), the opera browsers, and many, many more... there is also fennec, but its not really there yet...
  • #13 * webkit and opera do fine* webkit rules - but thats noth the whole truth about webkit, more later... * that table is more than a year old - but still ok to check. -&gt; ow its time for some:
  • #14 * to 3) May 2010, numbers by admob
  • #15 * My phone reads 1,000 entries from localStorage in 16.4ms.
  • #16 * (Chrome: 240ms, Firefox: 77ms, Safari: 1.4ms) * anyway, thats wicked fast (it&amp;#x2018;s a phone)! -&gt; but, the main thing is:
  • #17 On modern phones, perf is pretty good, but don&amp;#x2018;t go too far, and:
  • #18 test your code on as many devices as possible! -&gt; but, what you will want to do, is:
  • #19 * or, mobile-capable websites (still yeah!) * webapps and websites are the same (for me and for now, at least). * what applies to webapps, also applies to websites -&gt; to turn an a webapp into a native app :
  • #20 * so they can be ditsributed to appStores * but, no need, iTunes also holds webApps * or, on iOS, you can use -&gt;
  • #21 * the first leads to the navigator.standalone property * home-button -&gt; website w/out chrome * device-width!! -&gt; now back to js, and to some pitfalls
  • #22 * most differences in JS are founded in different ages of the browsers * iOS 2.x is dead, but Android 1.5/1.6 is not
  • #23 * iOS 4 does more, but only 50k * iOS 3.2 is shipped w/ iPad * dont just throw a super-sized JS-Framework into a phone!! * thanks to Ryan Grove from YUIBlog
  • #24 * a div with onclick/ontouch event connection will not work using keyboards! * i know more than one app ported from iphone to android that simply dont work.
  • #25 * dont just port JS code to a multitouch device, think about it! * click events are fired, but behave different (no dblclick, e.g.) * touch events are cool, check them out
  • #26 * JS runs fine on modern mobile devices * don&amp;#x2018;t be afraid, code - but test.