Top Banner
Build the mobile web you want @k88hudson
73

Build the mobile web you want

Aug 06, 2015

Download

Technology

k88hudson
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: Build the mobile web you want

Build the mobileweb you want

@k88hudson

Page 2: Build the mobile web you want

The webis broken

Page 3: Build the mobile web you want
Page 4: Build the mobile web you want

UI perf

Offline/intermittent

network

Auth/security

Device/OS Integration

Page 5: Build the mobile web you want

– browser vendors

We’re working on it

Page 6: Build the mobile web you want

Native Web

ok pretty bad

terrible, working on it

meh

ok sometimes

Page 7: Build the mobile web you want

What do we do?

Page 8: Build the mobile web you want

“I feel like it’s time to revisit the web vs. native

debate, and concede defeat — or, at least, concede that the web cannot, and should not, compete with native when it comes to complex, app-like structures.”

Page 9: Build the mobile web you want

“Conceding defeat will force us to rethink the web’s purpose and

unique strengths — and that’s long overdue.”

Page 10: Build the mobile web you want

This is a totally reasonable, rational argument

Page 11: Build the mobile web you want

2004

Page 12: Build the mobile web you want

Kazaa

Wallpapers

Page 13: Build the mobile web you want
Page 14: Build the mobile web you want
Page 15: Build the mobile web you want
Page 16: Build the mobile web you want

An app… in JavaScript?!

Page 17: Build the mobile web you want

When I decided to write the Gmail interface in Javascript, pretty much everyone who knew anything about Javascript or web browsers told me that it was a bad idea. It had been tried in the past, and always ended in disaster.

– Paul Buchheit, lead developer of Gmail in 2004

Page 18: Build the mobile web you want
Page 19: Build the mobile web you want

“While I am personally opposed to all use of JavaScript, I understand that JavaScript can do some things that you can't do with normal HTML…

Just remember, if Amazon can [do without JavaScript], so can you.”

– “Anti-JavaScript FAQ”

Page 20: Build the mobile web you want

“A lot of designers think it’s their god-given right to annoy the hell out of visitors with bulky

Javascript effects, so turning off Javascript is almost a requirement

to visit some websites.”

– “Javascript is Evil”

Page 21: Build the mobile web you want

“Blindly accepting a high level of security risk on the web [by

enabling JavaScript] is as shaky as a ride on the Canadian space

shuttle (made of birch bark and pine gum)”

– “Stupid JavaScript Security Tricks”

Page 22: Build the mobile web you want

“The XML HTTP thing”

Page 23: Build the mobile web you want

“The XML HTTP thing”

Page 24: Build the mobile web you want

You are here because of a massive hack

Page 25: Build the mobile web you want
Page 26: Build the mobile web you want

Now is the time to hack

Page 27: Build the mobile web you want

The three levels of hack

Page 28: Build the mobile web you want

Test new features before their time

The First Level of Hack

Page 29: Build the mobile web you want

Service workers!!

(Coming to FF in fall 2015)

Page 30: Build the mobile web you want

Transpile! Polyfill!

Page 31: Build the mobile web you want

(This is not controversial stuff)

Page 32: Build the mobile web you want

Build new abstractionsThe Second Level of Hack

Page 33: Build the mobile web you want
Page 34: Build the mobile web you want

https://github.com/filerjs/filer

Page 35: Build the mobile web you want
Page 36: Build the mobile web you want

Blow sh*t upThe Third Level of Hack

Page 37: Build the mobile web you want

What if you could hack your user agent?

Page 38: Build the mobile web you want

https://wiki.mozilla.org/Mobile/Get_Involved

Page 39: Build the mobile web you want

“Hybrid apps”

Page 40: Build the mobile web you want

https://cordova.apache.org/

Page 41: Build the mobile web you want

Let’s build our own

Page 42: Build the mobile web you want
Page 43: Build the mobile web you want
Page 44: Build the mobile web you want

• Poor offline experience • Memory leaks in long-lived processes

• UI perf • Android <4.4

Page 45: Build the mobile web you want

Basic architecture

Page 46: Build the mobile web you want

Android Activity

Page 47: Build the mobile web you want

Create an activity

MainActivity

main_activity

AndroidManifest.xml

Page 48: Build the mobile web you want

Android Activity

Web view

Page 49: Build the mobile web you want

Instantiate a WebView

MainActivity.java

Page 50: Build the mobile web you want

What about Android 4.2, 4.0, ..?

Page 51: Build the mobile web you want

https://crosswalk-project.org/

Page 52: Build the mobile web you want

Android Activity

Web view

Communication Layer

Page 53: Build the mobile web you want

Loading resources

Page 54: Build the mobile web you want

Expose a custom Java interface to Javascript

Page 55: Build the mobile web you want

Expose a custom Java interface to JavascriptMainActivity.java

index.js

Page 56: Build the mobile web you want
Page 57: Build the mobile web you want

App.java

Page 58: Build the mobile web you want

Similar to server side routing, but we get native

Android transitions

Page 59: Build the mobile web you want

What about state?

Page 60: Build the mobile web you want

Web: React view

Android: Router, SharedPreferences

Page 61: Build the mobile web you want

JavascriptInterface.java

Passing route params

MainComponent.js

Page 62: Build the mobile web you want

JavascriptInterface.java

Caching state

Page 63: Build the mobile web you want

Caching stateMainComponent.js

Page 64: Build the mobile web you want

Device integration?

Page 65: Build the mobile web you want

Camera integration

Page 66: Build the mobile web you want

Camera integration

Page 67: Build the mobile web you want

What else?• Bind to Android’s offline network caching utilities

• Hook into native gestures

• Device/OS integration

• ???

Page 68: Build the mobile web you want

Will it work? Who knows…

Page 69: Build the mobile web you want

You get to build the web you want

Page 70: Build the mobile web you want
Page 71: Build the mobile web you want

is finding adequate solutions to problems that matter, in a way that someone in the future can understand and improve on.

Really good engineering

Page 72: Build the mobile web you want

Hack the good hack, my friends

Page 73: Build the mobile web you want

@k88hudson