sebastian burkhart — berlin.apps.js nov 2012 talk

72
Copilot Creating a mobile web app in 8 days: What we learned. Friday, November 30, 12

Upload: sebastian-burkhart

Post on 12-May-2015

1.277 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

CopilotCreating a mobile web app in 8 days: What we learned.

Friday, November 30, 12

Page 2: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Sebastian Burkhart

github: opyhtwitter: opyhapp.net: hypo

working at bitcrowd.net, Berlin

Friday, November 30, 12

Page 3: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Content: Technical & Design pitfalls to avoid

Friday, November 30, 12

Page 4: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

= Checklist for your mobile projects

Friday, November 30, 12

Page 5: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

http://m.moviepilot.com

Friday, November 30, 12

Page 6: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Friday, November 30, 12

Page 7: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Friday, November 30, 12

Page 8: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Friday, November 30, 12

Page 9: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Friday, November 30, 12

Page 10: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Friday, November 30, 12

Page 11: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

App specs

Friday, November 30, 12

Page 12: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Minimal Rails appBackbone.EventsBackbone.Router

Zepto

App specs

Friday, November 30, 12

Page 13: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Used for -like drill-down navigation

and -like side-bar menu

swipe.js

Friday, November 30, 12

Page 14: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Has touch event handlers +transform / transition CSS

swipe.js

Friday, November 30, 12

Page 15: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Remove display: table-row for speed!

swipe.js

Friday, November 30, 12

Page 16: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Micro MVC framework

Friday, November 30, 12

Page 17: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Inspired by iOS UIKit ViewController classes

Micro MVC framework

Friday, November 30, 12

Page 18: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

UITabBarController + UINavigationControllers

Micro MVC framework

Friday, November 30, 12

Page 19: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Technical lessons

Friday, November 30, 12

Page 20: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Your desktop browser lies. :)

Friday, November 30, 12

Page 21: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Test every browser / device combination.

Friday, November 30, 12

Page 22: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Chrome/Nexus 4 ≠ Chrome/Galaxy S III ≠ built-in browser/Samsung S III

Test every browser / device combination.

Friday, November 30, 12

Page 23: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

In our case: iPhone 3G faster than Galaxy S3

Test every browser / device combination.

WTF

Friday, November 30, 12

Page 24: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

→ Don't develop with only one device type.

→ You will need to debug directly on your devices (see Emma's talk).

Friday, November 30, 12

Page 25: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

iOS• Use Safari's Inspector via USB

• Enable debugging in your phone settings

• Enable Develop menu in desktop Safari preferences

• Connect phone via USB

• Open inspector via Develop menu item

Android• Download Android SDK

• Enable USB web debugging on phone (Settings > Advanced > Developer tools)

• Connect phone via USB

• Use adb forward tcp:9222 localabstract:chrome_devtools_remote on the command line to start a debugging server

• Get a remote inspector running inside your desktop browser by navigating to localhost:9222

• Often proposed on the web, but: adb logcat is not reliable for seeing console.log output

Friday, November 30, 12

Page 26: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Loading too many images will crash your browser

Friday, November 30, 12

Page 27: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

overflow: scrollis working now.

What’s cool:

Friday, November 30, 12

Page 28: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

overflow: scrollis working now (Almost.)

What’s cool:

Friday, November 30, 12

Page 29: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

overflow: scrollAvoid more than one top element

Friday, November 30, 12

Page 30: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

overflow: scrollUse it together with -webkit-overflow-

scrolling: touch to enable native scrolling with bounce and momentum

Friday, November 30, 12

Page 31: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

overflow: scroll

Build a fallback solution if you need to support older devices

Friday, November 30, 12

Page 32: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

scrollTop is broken on Android

https://code.google.com/p/android/issues/detail?id=19625

(You can’t set it via JS.)

Friday, November 30, 12

Page 33: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

scrollTop is broken on AndroidNo good solutions available: Libs like iScroll-4 don’t work reliably Fallback to a non-single-page app? Ignore and wait for browser updates? Use transforms instead?

Friday, November 30, 12

Page 34: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

scrollTop is broken mkII= Many Android browsers reset the scrollTop property to 0 when appending aDOM element.

Friday, November 30, 12

Page 35: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

300ms lag on tap eventsMobile browsers wait for double-tap events.

If you want a native app-like feeling: create your own tap event handling.

Friday, November 30, 12

Page 36: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Expect weird bugsSome examples following…

Friday, November 30, 12

Page 37: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Expect weird bugsSwallowed events (many browsers)

Friday, November 30, 12

Page 38: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Expect weird bugs

A speci"c <div> had to wider than 355px to not break performance down completely

(iOS)

Friday, November 30, 12

Page 39: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Expect weird bugs

Touch events were delivered to wrong elements (Android, S III, built-in browser)

Friday, November 30, 12

Page 40: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Expect weird bugsFacebooks new mobile comment widget

seems not to work on mobile (the desktop version does, though)

Friday, November 30, 12

Page 41: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

About performance…

Friday, November 30, 12

Page 42: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

About performance…Don't forget your HTML/JS apps compete with native

apps.

Friday, November 30, 12

Page 43: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Requests may be very slow

Friday, November 30, 12

Page 44: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Requests may be very slowHave HTML content preloaded if possible.

HTML strings in a JS map worked well for us.

Friday, November 30, 12

Page 45: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Add caching on server-side

Friday, November 30, 12

Page 46: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Add caching on server-sideMake your served content state-independent.

Use caching services, e.g. fastly.

Friday, November 30, 12

Page 47: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Make rendering fast

Friday, November 30, 12

Page 48: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Make rendering fastPrefer native scrolling and positioning over transforms

Friday, November 30, 12

Page 49: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Make rendering fast

Friday, November 30, 12

Page 50: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Make rendering fastAvoid z-index

Friday, November 30, 12

Page 51: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Make rendering fast

Friday, November 30, 12

Page 52: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Make rendering fastAvoid big <div>s, their content may have to be cached in

graphics memory as bitmap

Friday, November 30, 12

Page 53: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Make rendering fast

Friday, November 30, 12

Page 54: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Make rendering fastAvoid jQuery/Zepto's DOM manipulation methods like

append() etc., as they traverse/copy whole DOM structures on JS level.

Friday, November 30, 12

Page 55: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Make rendering fast

Friday, November 30, 12

Page 56: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Make rendering fastUse exactly sized images for smoother scrolling (might

be much effort if you have to support many display sizes…)

Friday, November 30, 12

Page 57: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Make rendering fast

Friday, November 30, 12

Page 58: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Make rendering fastGood news: CSS box-shadows and gradients are fast on

most devices.

Friday, November 30, 12

Page 59: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Make rendering fast

Friday, November 30, 12

Page 60: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Make rendering fastGood news: CSS box-shadows and gradients are fast on

most devices.

(...but make them <10px wide. And use inset shadows sparingly, and not over images.)

Friday, November 30, 12

Page 61: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Design for small displays

Friday, November 30, 12

Page 62: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

iOS Human Interface Guidelines

Friday, November 30, 12

Page 63: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

“44 x 44 points is the comfortable minimum size of a tappable UI element.”

http://bit.ly/V6OmO9

Friday, November 30, 12

Page 64: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Touchable UI areasshould be big

Friday, November 30, 12

Page 65: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Responsive design

Friday, November 30, 12

Page 66: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Responsive designbackground-position: 50% 30%

background-size: cover

…"ts landscape and portrait images.

Friday, November 30, 12

Page 67: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Responsive design

Don’t forget to vary screen height when testing CSS media queries

Friday, November 30, 12

Page 68: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Responsive design

Don’t forget to vary screen height when testing CSS media queries

very low in landscape mode

Friday, November 30, 12

Page 69: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Responsive design

very low in Facebook app

Don’t forget to vary screen height when testing CSS media queries

Friday, November 30, 12

Page 70: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Responsive design

low because of toolbars :(

Don’t forget to vary screen height when testing CSS media queries

Friday, November 30, 12

Page 71: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Responsive designDon’t hide the address bar just because you can.

Friday, November 30, 12

Page 72: Sebastian Burkhart — Berlin.apps.js Nov 2012 Talk

Sebastian Burkhart

github: opyhtwitter: opyhapp.net: hypo

working at bitcrowd.net, Berlin

Friday, November 30, 12