Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Get Ahead with HTML5 on Moible

Get Ahead with HTML5 on Moible

Markus Kobler

June 16, 2011
Tweet

More Decks by Markus Kobler

Other Decks in Programming

Transcript

  1. AppCache very simple to add... 1) List all your resources

    in a manifest file 2) Reference your manifest file in the <html> tag
  2. Update Manifest file EVERY time ANY required resource changes If

    resources fail to download, app will not update!
  3. window.applicationCache.addEventListener('updateready', function(e) { if (window.applicationCache.status == window.applicationCache.UPDATEREADY) { window.applicationCache.swapCache(); window.location.reload();

    } }, false); Update Manifest file EVERY time ANY required resource changes If resources fail to download, app will not update! Your old version will always start first (Browser does not know if it has a connection initially)
  4. A Simple Key/Value store for strings Web Storage localStorage.setItem("bar", foo);

    localStorage["bar"] = foo; But nothing to stop you from encoding JSON, image data, etc
  5. A Simple Key/Value store for strings Tied to a browser

    session or longer (similar to cookies) Web Storage localStorage.setItem("bar", foo); localStorage["bar"] = foo; But nothing to stop you from encoding JSON, image data, etc
  6. Web SQL Database var db = openDatabase('example', '1.0', 'Checkins', 8192);

    db.transaction(function(tx) { tx.executeSql("create table if not exists " + "checkins(id integer primary key asc, time integer, latitude float,longitude float)" ); }); Power of a client side RDBS db.transaction(function(tx) { tx.executeSql( "insert into checkins (time, latitude, longitude) values (?,?,?);", [checkin.time, checkin.latitude, checkin.longitude], onSuccessHandler, onErrorHandler ); });
  7. Web SQL Database That’s both good and bad var db

    = openDatabase('example', '1.0', 'Checkins', 8192); db.transaction(function(tx) { tx.executeSql("create table if not exists " + "checkins(id integer primary key asc, time integer, latitude float,longitude float)" ); }); Power of a client side RDBS db.transaction(function(tx) { tx.executeSql( "insert into checkins (time, latitude, longitude) values (?,?,?);", [checkin.time, checkin.latitude, checkin.longitude], onSuccessHandler, onErrorHandler ); });
  8. Web SQL Database That’s both good and bad Effectively a

    JavaScript wrapper around SQLite... var db = openDatabase('example', '1.0', 'Checkins', 8192); db.transaction(function(tx) { tx.executeSql("create table if not exists " + "checkins(id integer primary key asc, time integer, latitude float,longitude float)" ); }); Power of a client side RDBS db.transaction(function(tx) { tx.executeSql( "insert into checkins (time, latitude, longitude) values (?,?,?);", [checkin.time, checkin.latitude, checkin.longitude], onSuccessHandler, onErrorHandler ); });
  9. New initiative around IndexedDB An indexed object store instead of

    SQL Early implementations in Chrome & Firefox But no support on mobile yet... Web DB set to be replaced
  10. CSS3 - Mostly well supported and might get you a

    long way Range of technologies to choose from
  11. CSS3 - Mostly well supported and might get you a

    long way Canvas and SVG - Canvas is great for pixel perfect changes - SVG if vectors are a better fit Range of technologies to choose from
  12. CSS3 - Mostly well supported and might get you a

    long way Canvas and SVG - Canvas is great for pixel perfect changes - SVG if vectors are a better fit WebGL - Not there yet for mobiles and tablets but coming soon... Range of technologies to choose from
  13. Think carefully about how you build your app Avoid using

    setTimeout() loops - Use requestAnimationFrame() instead Avoid excessive browser reflows wherever possible
  14. Think carefully about how you build your app Avoid using

    setTimeout() loops - Use requestAnimationFrame() instead Avoid excessive browser reflows wherever possible 3D CSS transforms can speed up Desktop/iOS apps but Android still has poor support
  15. Think carefully about how you build your app Avoid using

    setTimeout() loops - Use requestAnimationFrame() instead Avoid excessive browser reflows wherever possible Check out Paul Irish’s great blog posts for more info http://paulirish.com/2011/dom-html5-css3-performance/ 3D CSS transforms can speed up Desktop/iOS apps but Android still has poor support
  16. Familiar syntax for web developers Built on top of jQuery

    Provides useful mobile widgets It might be all you need...
  17. Familiar syntax for web developers Built on top of jQuery

    Provides useful mobile widgets It might be all you need... complex apps typically demand more
  18. Sencha Touch SproutCore - Both modern Open Source projects -

    Designed with pure JS mobile apps in mind - Backed by two well financed startups
  19. Google Web Toolkit Java (& XML) at core Mature and

    fully featured Works well with teams of Dev’s Aggressively optimised But will not be to everyone’s taste
  20. Useful Links Spec’s - http://www.whatwg.org/specs/web-apps/current-work/multipage/ - http://www.w3.org/TR/html5/offline.html - http://www.w3.org/TR/webstorage/ -

    http://www.w3.org/TR/IndexedDB/ - http://www.w3.org/TR/websockets/ Frameworks - http://jquerymobile.com/ - http://www.sencha.com/products/touch/ - http://www.sproutcore.com/ - http://code.google.com/webtoolkit/ Useful Links - http://www.html5rocks.com/ - http://caniuse.com/ - http://html5demos.com/ - http://www.browserscope.org/
  21. Image Credits Annie Mole - http://www.flickr.com/photos/anniemole/2424372024/sizes/l/in/photostream/ Yaniv Golan - http://www.flickr.com/photos/yghelloworld/4964999147/sizes/l/in/photostream/

    Achew *Bokehmon* - http://www.flickr.com/photos/achew/3987039984/in/photostream/ Liam Johnson - http://www.flickr.com/photos/livelavalove/4899123302/sizes/l/in/photostream/ Cdevers - http://www.flickr.com/photos/cdevers/4602805654/sizes/l/in/photostream/ Melvin Schlubman - http://www.flickr.com/photos/pauldineen/4871132100/sizes/l/in/photostream/ Melvin Schlubman - http://www.flickr.com/photos/pauldineen/4871130172/in/photostream/ Afagen - http://www.flickr.com/photos/afagen/4913607219/sizes/l/in/photostream/ Langley Research Center - Nasa http://grin.hq.nasa.gov/ABSTRACTS/GPN-2000-001907.html Ming Xia - http://www.flickr.com/photos/xiaming/476229544/