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

Open Source Junction

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers. →

Open Source Junction

I gave a talk about the FT web app at Open Source Junction 3, at Trinity College, Oxford.

Andrew Betts

April 20, 2012

Transcript

31 slides
  1. We’ve got a website for that HTML5, offline and the

    future of the mobile web Open Source Junction 3 Trinity College, Oxford 20-21 March 2012
  2. 2001: BlackBerry. Now we’re talking. (except ironically we’re not talking

    because Blackberry wouldn’t add phone capabilities for another 3 years)
  3. Challenges for the web •  Layout –  Adapt, adapt, adapt

    •  Navigation and interaction –  Interpreting touches is a subtle art •  Offline use –  Just reinvent the whole way the web works •  Rethink backend architecture –  Fewer pages, more APIs •  Analytics –  Record activity while user is offline
  4. Breaking it down •  Launching the app offline •  Making

    text content available offline •  Storing content images offline •  Dealing with quota limits •  Analytics
  5. Launching •  Application cache •  Manifest is atomic – download

    all or none – Boot page, fonts, sprites, splash screen, icons only. •  Webkit manifest bug – obscure naming of the manifest helps •  Set dynamic comment in manifest for dev
  6. Manifest contents •  Fonts •  Sprites •  Icons •  Splash

    screen •  One HTML page •  JavaScript •  HTML •  CSS YES   NO  
  7. CACHE MANIFEST # Version: 2012030613 /favicon.ico /lib/imgs/sprite.png /lib/imgs/splash-logo.jpg /lib/fonts/main.ttf FALLBACK:

    / /controller.html NETWORK: * Cached files Use network when possible Fallback for booting offline
  8. Boot process •  Fallback page is loaded from app cache

    •  Load resources from local storage – JS, CSS, HTML •  Use cookie to identify user •  Load requested content from local DB •  Display it    
  9. Offline text content •  Client side database •  IndexedDB is

    coming, SQLite works now. •  5MB for free, up to 50 with consent •  Use localStorage for index, as it's faster
  10. Offline images •  Lots. High turnover. Binary data. •  Client

    side database •  Download base64 encoded strings •  Render as data: URIs –  <img src=“data:image/png;……” /> •  Nice: Stops operators interfering •  Unfortunate: 30% bigger
  11. Tricks for super storage •  local storage and local DB

    use UTF-16 text •  That’s a minimum 2 bytes per character •  Pack ASCII into (pretend) UTF-16: if (in.length % 2 !== 0) in += ' '; for (i = 0, l = in.length; i < l; i+=2) { out += String.fromCharCode( (in.charCodeAt(i)*256) + string.charCodeAt(i+1) ); }
  12. Useful tools •  Charles – www.charlesproxy.com •  WeinRE – phonegap.github.com/weinre/ •  WebDriver

    for mobile browsers – http://code.google.com/p/selenium/wiki/ WebDriverForMobileBrowsers
  13. In summary •  Ease of use is critical. Adapt, adapt,

    adapt. •  The web can do this •  Web approach retains all the benefits of the web that you give up when building native.
  14. Questions? •  Andrew Betts •  [email protected] •  You should follow

    me on twitter here: – @triblondon •  Build this stuff: – assanka.net/jobs

More Decks by Andrew Betts

Other Decks in Technology