Top Banner
§ Making High Performance PhoneGap Apps How we made people think that Snowbuddy was a native app §
53

High Performance PhoneGap Apps

Jul 20, 2015

Download

Mobile

Syd Lawrence
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: High Performance PhoneGap Apps

§

Making High Performance

PhoneGap AppsHow we made people think that

Snowbuddy was a native app

§

Page 2: High Performance PhoneGap Apps

§

ABOUT US

Page 3: High Performance PhoneGap Apps

§

We 3 js

Page 4: High Performance PhoneGap Apps

Calvin Harris 18 Months App

Top 5 iOS Music App on the App Store

26% CTR to buy the album, pre-orders helped the album

debut at #1 in the Dance charts

Featured by both Apple & Google and coined “a piece of art from a Digital Rights Management point of view”

We decided to give Calvin’s album away for free, but with a twist.

You had to be dancing to listen to the music.

mobile OF THE DAY

Finalist

§

Page 5: High Performance PhoneGap Apps

NOW What’s That Song

Over 1 Million games played after less than 2 weeks

Over 300,000 users after less than 3 weeks

#2 iOS App across all apps (iPhone & iPad)

Featured by Facebook & Parse

An iPhone & iPad song quiz game for NOW That’s What I Call Music

§

Page 6: High Performance PhoneGap Apps

Standing Novation

Exhibited at The Tate Modern, June 2014

Exhibited in The Barbican, August 2013

Hack the Barbican South Place Hotel Award Winner

An interactive physical digital art installation. A serene moment in a vibrant digital space.

§

Page 7: High Performance PhoneGap Apps

UEFA Champions League

Custom made screens built around a giant statue in the centre of Lisbon displaying content from fans from all over the world and visualizing team support, lineups and game information.

§

Social content and data visualizations for the UEFA Champions League Final.

§

Page 8: High Performance PhoneGap Apps

Samsung Shoreditch Studio

“An awesome digital representation of a classic record store”

“Combining music and tech in the simplest possible way”

NFC triggered digital turntable.

Walk in, tap a record sleeve, play a song… simple.

§

Page 9: High Performance PhoneGap Apps

snowbuddy

40,000+ users

Best new app

“Best apps of 2014”

§

Page 10: High Performance PhoneGap Apps

§

“Did you use swift or objective-c?”

Page 11: High Performance PhoneGap Apps

§

What we used

Page 12: High Performance PhoneGap Apps

§

It’s Easy to write bad javascript

Page 13: High Performance PhoneGap Apps

§

7 tips for high performance phonegap apps

01 Use a JS Framework 02 Avoid Janky Animations 03 The Dreaded Tap Delay 04 Offline Syncing 05 Background Tasks 06 Avoid Memory Leaks 07 Use CrossWalk

Page 14: High Performance PhoneGap Apps

§

Disclaimer “The one true way”

Page 15: High Performance PhoneGap Apps

§

Use a JS Framework

01

Page 16: High Performance PhoneGap Apps

§

don’t reinvent the wheel

Page 17: High Performance PhoneGap Apps

§

A problem shared is a problem solved

Page 18: High Performance PhoneGap Apps

§

avoid Janky animations

02

Page 19: High Performance PhoneGap Apps

§

“Use css transitions”

Page 20: High Performance PhoneGap Apps

§

.el { top:0; transition:200ms top; } .el.animated { top:20px; }

Page 21: High Performance PhoneGap Apps

§

.el { top:0; transition:200ms top; } .el.animated { top:20px; }

Page 22: High Performance PhoneGap Apps

§

.el { top:0; transition:200ms transform; } .el.animated { transform:translate3d(0, 20px, 0); }

Page 23: High Performance PhoneGap Apps

§

The Dreaded tap delay

03

Page 24: High Performance PhoneGap Apps

§

300ms delay is *

Page 25: High Performance PhoneGap Apps

ontap

ontouchstart

ontouchend

onclick§

Page 26: High Performance PhoneGap Apps

§

FastClick.attach(document.body);

github.com/ftlabs/fastclick

Fastclick

Page 27: High Performance PhoneGap Apps

§

offline storage

04

Page 28: High Performance PhoneGap Apps

§

localstorage

has its issues

Page 29: High Performance PhoneGap Apps

§

let’s try the local file system!

Page 30: High Performance PhoneGap Apps

§

pouchdb it’s awesome

pouchdb.com

Page 31: High Performance PhoneGap Apps

var db = new PouchDB( 'myDB', { adapter: 'websql' } );

§

pouchdb

Page 32: High Performance PhoneGap Apps

db.put({ _id: 'wmas', awesome: true });

§

pouchdb

Page 33: High Performance PhoneGap Apps

db.get('wmas').then(function (doc) { // handle doc

}).catch(function (err) { console.log(err);

});

§

pouchdb

Page 34: High Performance PhoneGap Apps

§

background tasks

05

Page 35: High Performance PhoneGap Apps

§

updating the UI when the app is in the background

Page 36: High Performance PhoneGap Apps

§

updating the UI when the app is in the background

Page 37: High Performance PhoneGap Apps

document.addEventListener( 'pause', onPause, false );

document.addEventListener( 'resume', onResume, false );

§

Page 38: High Performance PhoneGap Apps

§

Avoid memory leaks

06

Page 39: High Performance PhoneGap Apps

§

Code reuse =

element reuse

Page 40: High Performance PhoneGap Apps

§

fully Remove media from memory

img.src = 'spacer.gif';

video.src = '';

Page 41: High Performance PhoneGap Apps

§

timeouts and

intervals

Page 42: High Performance PhoneGap Apps

§

timeouts and

intervals

Page 43: High Performance PhoneGap Apps

§

Test Evaluate Debug

Page 44: High Performance PhoneGap Apps

§

safari dev tools -> timelines

Page 45: High Performance PhoneGap Apps

§

Chrome DEv tools -> profiles

Page 46: High Performance PhoneGap Apps

§

instruments -> allocations

Page 47: High Performance PhoneGap Apps

§

use crosswalk

07

Page 48: High Performance PhoneGap Apps

§

Page 49: High Performance PhoneGap Apps

§

crosswalk it’s awesome

cordova plugin add https://github.com/MobileChromeApps/cordova-plugin-crosswalk-webview.git

Page 50: High Performance PhoneGap Apps

§

conclusion

Page 51: High Performance PhoneGap Apps

§

It’s Easy to write bad javascript

Page 52: High Performance PhoneGap Apps

§

It’s fun to write good javascript

Page 53: High Performance PhoneGap Apps

§

THANKS any questions?

@sydlawrence [email protected]