the ft eb pp coding responsively
play

The FT eb pp: Coding responsively Dr Robert Shilston - PowerPoint PPT Presentation

The FT eb pp: Coding responsively Dr Robert Shilston (rob@labs.ft.com) Director, FT Labs (@ftlabs) Historical comparison 1880 1900 1920 1940 1960 1980 2000 2020 Ne sprint orks o ffl ine Fast start up Portable


  1. The FT  eb  pp: Coding responsively Dr Robert Shilston (rob@labs.ft.com) Director, FT Labs (@ftlabs)

  2. Historical comparison 1880 1900 1920 1940 1960 1980 2000 2020

  3. Ne  sprint  orks o ffl ine Fast start up Portable Clipping/saving Long battery life Can be read in the dark Can be read in bright sunlight Updates in real time Cheap Electronic delivery Ubiquity Search Bookmarking Personalisation Sharing Deep linking

  4. ‘Traditional’  eb  orks o ffl ine Fast start up Portable Clipping/saving Long battery life Can be read in the dark Can be read in bright sunlight Updates in real time Cheap Electronic delivery Ubiquity Search Bookmarking Personalisation Sharing Deep linking

  5.  pps  orks o ffl ine Fast start up Portable Clipping/saving Long battery life Can be read in the dark Can be read in bright sunlight Updates in real time Cheap Electronic delivery Ubiquity Search Bookmarking Personalisation Sharing Deep linking

  6. HTML5 is HTML5 is not a ‘mobile thing’ not a ‘mobile thing’. . It’s It’s not an alternative not an alternative to native to native apps. apps. It’s a It’s a  ay of making ay of making better better  ebsites ebsites. .

  7.  elcome back to the elcome back to the  eb eb The FT  eb app provides a touch optimised user experience  ithout native code.

  8. Sometimes it’s  hat hat  e’ve done e’ve done But  e’ve learned a lot, so to be honest sometimes it’s  hat hat  e e  ould do if ould do if  e did it e did it again. again.

  9.  genda • Coding responsively – Layout and interactions – Connection state – OS • Development process – Branching and feature flags – Testing and deployment

  10. But first, let’s consider:  hat is an app? hat is an app?

  11.  hat is an ‘app’? • Built for a single platform • In an app store •  ritten in native code • Built for mobile • Designed for touch interactions NO TH  NKS

  12.  hat an ‘app’ is to us: app (n). app (n). a distributed computer soft  are application designed for optimal use on specific screen sizes and  ith particular interface technologies ,

  13. So let’s start:  hy code responsively? hy code responsively?

  14. Ne  devices

  15. Ho  an app might run Desktop Laptop Click Type Tablet Phone Move Touch In car screen  eroplane Speak Listen Games + TV console Point See Glasses Kiosk Think? Billboard  atch

  16. Layout and interactions • Screen size – Not the same as resolution • Instant touch feedback • Click and mouse hover e ff ects • Keyboard shortcuts • Reading experience – Easier to read narro  columns – Paragraph leading and guttering

  17. Fastclick • Speed up touch interactions • Eliminates 300ms lag <script src='fastclick.js'></script> window.addEventListener('load', function() { new FastClick(document.body); }, false);

  18. Scroller

  19. Flo  ed columns

  20. Flo  ed columns

  21. Reflo  ing

  22. Resizing

  23. Connection state Connection state Or  hy online and o ffl ine events should not be trusted to ans  er the question ‘are  e online?’

  24. navigator.onLine  re you online if? – You’ve got  ifi signal? – You’ve got 3G signal? – If DNS resolves? If T  itter loads? –  ill my site? –  ill Facebook?

  25. Q: If the value of navigator.onLine is true ,  hat does that mean?  : The device might be online.

  26. For  hen there’s no connection •  ppCache – Essential for o ffl ine functionality – Just use it to bootstrap your app. • LocalStorage – Great for code and templates • Cookies – Shared  ith the server – Included in every request •  ebSQL / IndexedDB – Great for content

  27. HTML5 ¡AppCache ¡for ¡ ini=al ¡page ¡load ¡ Splash ¡screen ¡ ¡ Beware. ¡ ¡AppCache ¡needs ¡ careful ¡handling. ¡ Basic ¡CSS ¡/ ¡Fonts ¡ Bootstrap ¡& ¡error ¡handling ¡ LocalStorage ¡for ¡code ¡ ¡ Main ¡app ¡code ¡ and ¡templates ¡ Main ¡CSS ¡& ¡HTML ¡templates ¡ Cookies ¡for ¡data ¡shared ¡ with ¡the ¡server ¡ Authen=ca=on ¡ Text ¡and ¡image ¡content ¡ WebSQL ¡/ ¡IndexedDB ¡for ¡ news ¡content ¡

  28. Squeezing your bits • Devices tend to limit HTML5 storage • Storing images o ffl ine: Base64 encoded data-URIs + UTF-16 storage encoding = Ine ffi cient

  29.  n image storage solution 1. Do  nload images as gzipped base64 2. Squeeze 2 ⅔ base64 characters into one UTF-16 character 3. Push that into the database 4. Reverse  hen rendering the page • Go to http://labs.ft.com/ to read more.

  30. Tips for coping  ith the net  ork • Batching your requests • Prioritise requests – User requested content first –  nalytics last • Progress bars – Sho  feedback fast – Be pessimistic

  31. One HTTP request! •  ggressive batching - collect requests asynchronously: api.add('getStory', {'path': '/1'}, callback1); api.add('getStory', {'path': '/2'}, callback2); api.send(callback3); api.add('analytics', params, callback4); api.send(callback5); • Callbacks per action and per group

  32. Going native Going native

  33.  cclimatised users •  ndroid – Back and Search buttons – Sharing: Intent.ACTION_SEND –  idgets – Background content do  nloading •  indo  s 8 – Sharing and Search charms – Home screen tile – Nav bar

  34. Search on  ndroid

  35. Search on  indo  s 8

  36. Search on iPad

  37. Search on iPhone

  38. Native  rappers • Invoke same core online  eb site •  rapper to  eb communication – via HTML5 postMessage – JavaScript function calls

  39. But  ith multiple devices, surely Managing the release process Managing the release process is hard?

  40. The Old Days: Branches Feature ¡“Banana” ¡ Dev ¡ Feature ¡“Apple” ¡ Merge ¡ Test ¡ Merge ¡ Trunk ¡ Release ¡ to ¡live ¡

  41. The alternative: Feature flags • Develop in one place • S  itch bits of code on and o ff if (Flags.get('WidgetEnabled’)) { ... } • Centralise those s  itches function get(flagname) { switch flagname: case 'WidgetEnabled': return isAndroid ... • Don’t associate multiple things to the same flag

  42. Feature flags: Override for testing Screenshot of flag tool

  43. Feature flags: Override for testing • Code example: function get(flagname) { flagoverrides = JSON.parse(localstorage.getItem('flags')); if (flagname in flagoverrides) { return flagoverrides[flagname]; } switch flagname: case 'AppleEnabled': return isAndroid ...

  44. Feature flags 2.0 • Server-side decisions control client side behaviour – Enable  /B feature release – Deploy features to di ff erent platforms – Push flags to client • Share flags client and server side – Get feedback on  /B testing • Remember analytics!

  45. Client-side code updates • The bootstrap code: – Runs  hat’s in localStorage –  sks the server if there’s a ne  version •  llo  beta users to get version first – Do  nloads it for use next time • Minimises  ppCache aggravation • Gives us complete control

  46. Final points Final points

  47. HTML5 sites can be HTML5 sites can be great great But building a good HTML5 But building a good HTML5 site is site is very hard very hard. .

  48. Summary • Less separation , more adaptation – Fe  er, more adaptive  ebsites • Less native , more  eb • HTML5 is NOT just a mobile solution, but a  ay of making better  ebsites . • Responsiveness is not about multiple static designs, it's a multi-variable equation

  49. Summary • appCache + localStorage + intelligent bootstrapping + good use of storage = reliable o ffl ine app • You don’t have to sacrifice features •  ith good optimisations you can get a great app experience

  50.  e're trying to help • Your dev team can use our code – github.com/ftlabs •  e blog about techniques at labs.ft.com • Consultancy available • Talks at conferences like this one

  51. “Don’t build “Don’t build native apps native apps, , build build  eb apps eb apps” -­‑ ¡Tim ¡Berners-­‑Lee ¡

  52. Thanks rob@labs.ft.com @FTLabs Do you  ant to build this stu ff ? Join in. jobs@labs.ft.com Image ¡credits:: ¡ ¡ hOp://cdn3.worldcarfans.co/2008/2/medium/9080214.017.Mini1L.jpg, ¡ ¡hOp://www.netbasic.com/blog/2008/10/mini-­‑car-­‑parking-­‑fail, ¡hOp://runningstopsigns.files.wordpress.com/ 2011/04/smart-­‑car.jpg ¡ ¡

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend