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

the ft eb pp coding responsively
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

The FT eb pp: Coding responsively

Dr Robert Shilston (rob@labs.ft.com) Director, FT Labs (@ftlabs)

slide-2
SLIDE 2

Historical comparison

1880 1900 1920 1940 1960 1980 2000 2020

slide-3
SLIDE 3
slide-4
SLIDE 4

orks offline Portable Long battery life Can be read in bright sunlight Cheap Ubiquity Bookmarking Sharing

Nesprint

Fast start up Clipping/saving Can be read in the dark Updates in real time Electronic delivery Search Personalisation Deep linking

slide-5
SLIDE 5

orks offline Portable Long battery life Can be read in bright sunlight Cheap Ubiquity Bookmarking Sharing

‘Traditional’ eb

Fast start up Clipping/saving Can be read in the dark Updates in real time Electronic delivery Search Personalisation Deep linking

slide-6
SLIDE 6

orks offline Portable Long battery life Can be read in bright sunlight Cheap Ubiquity Bookmarking Sharing

pps

Fast start up Clipping/saving Can be read in the dark Updates in real time Electronic delivery Search Personalisation Deep linking

slide-7
SLIDE 7

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. .

slide-8
SLIDE 8

elcome back to the elcome back to the eb eb

The FT eb app provides a touch optimised user experience ithout native code.

slide-9
SLIDE 9

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

  • uld do if e did it

e did it again. again.

slide-10
SLIDE 10

genda

  • Coding responsively

– Layout and interactions – Connection state – OS

  • Development process

– Branching and feature flags – Testing and deployment

slide-11
SLIDE 11

hat is an app? hat is an app?

But first, let’s consider:

slide-12
SLIDE 12

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

slide-13
SLIDE 13

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,

slide-14
SLIDE 14

hy code responsively? hy code responsively?

So let’s start:

slide-15
SLIDE 15

+

Desktop Click Point

Ho an app might run

Laptop Type Move Tablet Touch Phone Speak In car screen Listen eroplane TV Billboard Kiosk Games console Think? ???

slide-16
SLIDE 16

Layout and interactions

  • Screen size

– Not the same as resolution

  • Instant touch feedback
  • Click and mouse hover effects
  • Keyboard shortcuts
  • Reading experience

– Easier to read narro columns – Paragraph leading and guttering

slide-17
SLIDE 17

Floed columns

slide-18
SLIDE 18

Floed columns

slide-19
SLIDE 19

Scroller

slide-20
SLIDE 20

Fastclick

  • Speed up touch interactions
  • Eliminates 300ms lag

<script src='fastclick.js'></script> window.addEventListener('load', function() { new FastClick(document.body); }, false);

slide-21
SLIDE 21

Connection state Connection state

Or hy online and offline events should not be trusted to anser the question ‘are e online?’

slide-22
SLIDE 22

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?

slide-23
SLIDE 23

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

slide-24
SLIDE 24

For hen there’s no connection

  • ppCache

– Essential for offline 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

slide-25
SLIDE 25

Splash ¡screen ¡ Basic ¡CSS ¡/ ¡Fonts ¡ Bootstrap ¡& ¡error ¡handling ¡ Main ¡app ¡code ¡ Main ¡CSS ¡& ¡HTML ¡templates ¡ Authen=ca=on ¡ Text ¡and ¡image ¡content ¡ HTML5 ¡AppCache ¡for ¡ ini=al ¡page ¡load ¡ ¡

  • Beware. ¡ ¡AppCache ¡needs ¡

careful ¡handling. ¡ LocalStorage ¡for ¡code ¡ ¡ and ¡templates ¡ Cookies ¡for ¡data ¡shared ¡ with ¡the ¡server ¡ WebSQL ¡/ ¡IndexedDB ¡for ¡ news ¡content ¡

slide-26
SLIDE 26

Squeezing your bits

  • Devices tend to limit HTML5 storage
  • Storing images offline:

Base64 encoded data-URIs + UTF-16 storage encoding = Inefficient

slide-27
SLIDE 27
slide-28
SLIDE 28

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.
slide-29
SLIDE 29

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

slide-30
SLIDE 30

One HTTP request!

  • ggressive batching - collect requests

asynchronously:

  • Callbacks per action and per group

api.add('getStory', {'path': '/1'}, callback1); api.add('getStory', {'path': '/2'}, callback2); api.send(callback3); api.add('analytics', params, callback4); api.send(callback5);

slide-31
SLIDE 31

Going native Going native

slide-32
SLIDE 32

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

slide-33
SLIDE 33

Search on ndroid

slide-34
SLIDE 34

Search on indos 8

slide-35
SLIDE 35

Search on iPad

slide-36
SLIDE 36

Search on iPhone

slide-37
SLIDE 37

Native rappers

  • Invoke same core online eb site
  • rapper to eb communication

– via HTML5 postMessage – JavaScript function calls

slide-38
SLIDE 38

Managing the release process Managing the release process

But ith multiple devices, surely is hard?

slide-39
SLIDE 39

The Old Days: Branches

Test ¡ Dev ¡ Trunk ¡ Feature ¡“Apple” ¡ Feature ¡“Banana” ¡ Release ¡ to ¡live ¡ Merge ¡ Merge ¡

slide-40
SLIDE 40

The alternative: Feature flags

  • Develop in one place
  • Sitch bits of code on and off
  • Centralise those sitches
  • Don’t associate multiple things to the same flag

function get(flagname) { switch flagname: case 'WidgetEnabled': return isAndroid ... if (Flags.get('WidgetEnabled’)) { ... }

slide-41
SLIDE 41

Feature flags: Override for testing

Screenshot of flag tool

slide-42
SLIDE 42

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 ...

slide-43
SLIDE 43

Feature flags 2.0

  • Server-side decisions control client side

behaviour

– Enable /B feature release – Deploy features to different platforms – Push flags to client

  • Share flags client and server side

– Get feedback on /B testing

  • Remember analytics!
slide-44
SLIDE 44

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
slide-45
SLIDE 45

Final points Final points

slide-46
SLIDE 46

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. .

slide-47
SLIDE 47

“The biggest mistake e made as a company as betting too much on HTML5 as opposed to native,”

“It just asn’t ready”

slide-48
SLIDE 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

slide-49
SLIDE 49

Summary

  • appCache + localStorage + intelligent

bootstrapping + good use of storage = reliable offline app

  • You don’t have to sacrifice features
  • ith good optimisations you can get a great

app experience

slide-50
SLIDE 50

e're trying to help

  • Your dev team can use our code

– github.com/ftlabs

  • e blog about techniques at labs.ft.com
  • Talks at conferences like this one
slide-51
SLIDE 51

“Don’t build “Don’t build native apps native apps, , build

build eb apps eb apps”

  • ­‑ ¡Tim ¡Berners-­‑Lee ¡
slide-52
SLIDE 52

Thanks

rob@labs.ft.com @FTLabs Do you ant to build this stuff? 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 ¡ ¡