Mobile HTM5 apps that can compete with native

Nolan Lawson

HTC Magic, 2009

htc magic
my android apps
html, css, and js
cordova
phonegap
node-webkit
atom shell
  • Android
  • iOS
  • Windows Phone
  • Blackberry
  • Firefox OS
  • Web
  • Windows
  • OS X
  • Linux
  • Chrome OS
  • etc.
mark zuckerburg says the mobile web ain't ready

Nexus 6, 2014

nexus 6
  • Animations
  • Android
  • Frameworks
  • Offline-first

Animations smooth as butter

JavaScript animations
tortoise
Normal CSS animations
hare
Hardware-accelerated CSS animations
cheetah
JavaScript animation (left) vs. hardware-accelerated CSS animation (right)
translate3d
scale3d
rotate3d
opacity
top / left
top / left / translateZ(0)
translate3d
Full FPS demo (see also Jake Archibald vid in sources)

The Android problem

Android is the new IE

crosswalk home page
Android 4.4.4 WebView (left, Chromium v33) vs. Chrosswalk (right, Chromium v38)

Pick your frameworks carefully

tweet, Looking fwd to js framework authors getting smartphones and trying their stuff out on em someday.

Mobile-optimized frameworks

ionic framework
famous framework
appgyver framework
Angular ng-repeat (left) vs. Ionic collection-repeat (right)

Offline-first

Ilya Grigorik talks about slow mobile networks
Ilya Grigorik - Breaking the 1000ms Time to Glass Mobile Barrier

Offline-first libraries

  • PouchDB
  • LocalForage
  • YDN-DB
  • Hoodie
  • Lawnchair
  • RemoteStorage
  • MakeDrive
  • IndexedDBShim
pouchdb-lru-cache
+
blob-util
=
easy offline images
Loading images on a slow connection (left) vs. Cached images in PouchDB (right)

var db = new PouchDB('my-images');
db.initLru(5000000); // store 5 MB max

function getImageSrc(src) {
  return db.lru.get(src).then(function (blob) {
    return blobUtil.createObjectURL(blob); // cached
  }).catch(function () { // not cached
    return blobUtil.imgSrcToBlob(src).then(function (blob) {
      return db.put(src, blob); // cache it
    }).then(function () {
      return src;
    });
  });
}
          
  • Harness the GPU for animations
  • Use Crosswalk for Android
  • Choose your frameworks wisely
  • Go offline-first

Sources

Tools