Top Banner
extreme web performance for mobile devices maximiliano @rtman rt.mobi San Francisco, April, 20th 2015
186
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: Extreme Web Performance for Mobile Device Fluent 2015

extreme web performance for mobile devices

maximiliano @firtman firt.mobi

San Francisco, April, 20th 2015

Page 2: Extreme Web Performance for Mobile Device Fluent 2015
Page 3: Extreme Web Performance for Mobile Device Fluent 2015
Page 4: Extreme Web Performance for Mobile Device Fluent 2015

NEW!SOON!

Page 5: Extreme Web Performance for Mobile Device Fluent 2015
Page 6: Extreme Web Performance for Mobile Device Fluent 2015

Slides, links and tests firtman.github.io/fluent

Page 7: Extreme Web Performance for Mobile Device Fluent 2015

questionsyes, please

QA at the end (also Office Hours tomorrow 2.15)

Page 8: Extreme Web Performance for Mobile Device Fluent 2015

performance + mobile + web

1- Mobile Web today 2- Performance & Mobile 3- Tools 4- Initial loading & perception 5- Responsiveness & experience

Page 9: Extreme Web Performance for Mobile Device Fluent 2015
Page 10: Extreme Web Performance for Mobile Device Fluent 2015

first…

Web Performance Optimization How important WPO is for conversion

Page 11: Extreme Web Performance for Mobile Device Fluent 2015

1- mobile web today*

*today: april 2015

Page 12: Extreme Web Performance for Mobile Device Fluent 2015

1- mobile web today

- Web Platforms - The Android’s problem

Page 13: Extreme Web Performance for Mobile Device Fluent 2015

web platforms

Page 14: Extreme Web Performance for Mobile Device Fluent 2015

iOS and Android

web platforms

Page 15: Extreme Web Performance for Mobile Device Fluent 2015

Adobe Digital Index NetMarketShare Akamai.io Wikimedia Stats StatCounter MOVR by WURFL

web platformsLinks at firtman,github.io/fluent

Page 16: Extreme Web Performance for Mobile Device Fluent 2015

web platformsOthers

4%

Windows Phone 3%

Opera 5%

iOS50%

Android38%

Page 17: Extreme Web Performance for Mobile Device Fluent 2015

web platforms

iOS50%

Safari100%

Page 18: Extreme Web Performance for Mobile Device Fluent 2015

web platforms

iOS50%

Apps (Web View) 12%

Safari88%

Page 19: Extreme Web Performance for Mobile Device Fluent 2015

web platforms

iOS50%

7.x 19%

6.x2%

8.x79%

Source: Apple

Page 20: Extreme Web Performance for Mobile Device Fluent 2015

web platforms

InApp iOS 5%

Safari iOS79%

Safari iOS836%

Android38%

Page 21: Extreme Web Performance for Mobile Device Fluent 2015

web platforms

Android38%

Page 22: Extreme Web Performance for Mobile Device Fluent 2015

web platforms

Android38% ?

Page 23: Extreme Web Performance for Mobile Device Fluent 2015

web platforms

Android38% Browser

50%Chrome

50%

Page 24: Extreme Web Performance for Mobile Device Fluent 2015
Page 25: Extreme Web Performance for Mobile Device Fluent 2015

-1% month

Page 26: Extreme Web Performance for Mobile Device Fluent 2015
Page 27: Extreme Web Performance for Mobile Device Fluent 2015

web platforms

Page 28: Extreme Web Performance for Mobile Device Fluent 2015

web platforms

Page 29: Extreme Web Performance for Mobile Device Fluent 2015

web platforms

Page 30: Extreme Web Performance for Mobile Device Fluent 2015

LG G3

Page 31: Extreme Web Performance for Mobile Device Fluent 2015

web platforms

Android38%

Samsung20%

Browser30%

Chrome50%

Page 32: Extreme Web Performance for Mobile Device Fluent 2015
Page 33: Extreme Web Performance for Mobile Device Fluent 2015
Page 34: Extreme Web Performance for Mobile Device Fluent 2015
Page 35: Extreme Web Performance for Mobile Device Fluent 2015

web platforms

iOS50%

Android38%

Page 36: Extreme Web Performance for Mobile Device Fluent 2015

web platforms

Samsung10%

Android14%

Others4%

Windows Phone 3%

Opera 5%InApp iOS

5%

Safari iOS79%

Safari iOS836%

Chrome15%

Others?

• Firefox • UC Browser • Nokia Browser • BlackBerry Browser

Page 37: Extreme Web Performance for Mobile Device Fluent 2015

1- mobile web today

- Understand the real ecosystem - Android browsers - Don’t think you are an average user - Everything will change

Page 38: Extreme Web Performance for Mobile Device Fluent 2015

2- mobile & performance

- Perception - Differences - Cellular networks - Responsive Web Design

Page 39: Extreme Web Performance for Mobile Device Fluent 2015

immediate feedback 100ms

perception

Jakob Nielsen - Usability Engineering

Page 40: Extreme Web Performance for Mobile Device Fluent 2015

immediate feedback <100ms

keeping user’s flow of thoughts <1s

perception

Jakob Nielsen - Usability Engineering

Page 41: Extreme Web Performance for Mobile Device Fluent 2015

500ms delay, +26% user’s frustration

perception

Source: Radware

Page 42: Extreme Web Performance for Mobile Device Fluent 2015

why do we need special care on mobile?

Page 43: Extreme Web Performance for Mobile Device Fluent 2015

CPU and GPU

Memory

differences

Page 44: Extreme Web Performance for Mobile Device Fluent 2015

CPU and GPU

Memory

differences

5x

Page 45: Extreme Web Performance for Mobile Device Fluent 2015

Wifi

differences

Page 46: Extreme Web Performance for Mobile Device Fluent 2015

Wifi, public spaces?

differences

Page 47: Extreme Web Performance for Mobile Device Fluent 2015

Cellular connections

differences

Page 48: Extreme Web Performance for Mobile Device Fluent 2015

We have 4G! We don't need to worry about performance...

(

)

Page 49: Extreme Web Performance for Mobile Device Fluent 2015
Page 50: Extreme Web Performance for Mobile Device Fluent 2015

cellular

0

25

50

75

100

US Western Europe Asia Global

4G 2G/3G

Only 4% is on 4G globally

Page 51: Extreme Web Performance for Mobile Device Fluent 2015

cellular

0

25

50

75

100

US Western Europe Asia Global

4G 2G/3G

~30% of the time 4G was not used

Page 52: Extreme Web Performance for Mobile Device Fluent 2015

But that is going to change quickly…

(

)

Page 53: Extreme Web Performance for Mobile Device Fluent 2015

2019?85% in USA and 30% in Europewill be on 4G

(

)

Source: Ericsson Mobility Report

Page 54: Extreme Web Performance for Mobile Device Fluent 2015

Real Bandwidth (Mbps)cellular networks

0 2 4 6 8

2G 3G Wifi 4G

Page 55: Extreme Web Performance for Mobile Device Fluent 2015

RTT - latencycellular networks

2G

3G

4G

Home

0 250 500 750 1000

Min Max

Page 56: Extreme Web Performance for Mobile Device Fluent 2015

latency

request

bandwidth

Page 57: Extreme Web Performance for Mobile Device Fluent 2015

Safari, Chrome, Android 91%

Page 58: Extreme Web Performance for Mobile Device Fluent 2015

Safari, Chrome, Android 71%91%

Page 59: Extreme Web Performance for Mobile Device Fluent 2015

1%

7%

18%

Other non-Android, non-iOS 10%

Safari, Chrome, Android 71%91%

Page 60: Extreme Web Performance for Mobile Device Fluent 2015

responsive web design

Page 61: Extreme Web Performance for Mobile Device Fluent 2015
Page 62: Extreme Web Performance for Mobile Device Fluent 2015

Responsive Web Design is a TOOL

Page 63: Extreme Web Performance for Mobile Device Fluent 2015

Responsive Web Design is NOT a GOAL

Page 64: Extreme Web Performance for Mobile Device Fluent 2015

Users DON’T care if your site is RESPONSIVE

(in terms of RWD)

Page 65: Extreme Web Performance for Mobile Device Fluent 2015

Users DO care if the site is FAST

Page 66: Extreme Web Performance for Mobile Device Fluent 2015

responsive web design

Source: guypo.com/rwd2014

Page 67: Extreme Web Performance for Mobile Device Fluent 2015

responsive web design

Source: guypo.com/rwd2014

43% more requests

compared with a mobile site

Page 68: Extreme Web Performance for Mobile Device Fluent 2015

responsive web design

Source: guypo.com/rwd2014

129% more data transfer

compared with a mobile site

Page 69: Extreme Web Performance for Mobile Device Fluent 2015

responsive web design

Source: guypo.com/rwd2014

87% more CPU time

compared with a mobile site

Page 70: Extreme Web Performance for Mobile Device Fluent 2015

2- mobile and performance- Perception: 1s threshold - RTT latency - Test on low hardware and 2G/3G - RWD harms performance

Page 71: Extreme Web Performance for Mobile Device Fluent 2015

3- tools

Page 72: Extreme Web Performance for Mobile Device Fluent 2015

3- tools- where - measuring loading times - measuring responsiveness - online tools - html5 apis

Page 73: Extreme Web Performance for Mobile Device Fluent 2015

Simulator & Emulator

Real device

where

Page 74: Extreme Web Performance for Mobile Device Fluent 2015

emulators

Samsung10%

Android15%

Others4%

Windows Phone 3%

Opera 5%

InApp Browser iOS 5%

Safari iOS45%

Chrome14%

Page 75: Extreme Web Performance for Mobile Device Fluent 2015

emulators

Samsung10%

Android15%

Others4%

Windows Phone3%

Opera 5%

InApp Browser iOS 5%

Safari iOS45%

Chrome14%

Page 76: Extreme Web Performance for Mobile Device Fluent 2015

emulators

Samsung10%

Android15%

Others4%

Windows Phone 3%

Opera 5%

InApp Browser iOS 5%

Safari iOS45%

Chrome14%

Page 77: Extreme Web Performance for Mobile Device Fluent 2015

DEMO

Page 78: Extreme Web Performance for Mobile Device Fluent 2015

online tools

Page 79: Extreme Web Performance for Mobile Device Fluent 2015

online tools

Page 80: Extreme Web Performance for Mobile Device Fluent 2015

online tools

Page 81: Extreme Web Performance for Mobile Device Fluent 2015

online tools

Page 82: Extreme Web Performance for Mobile Device Fluent 2015

remote inspectors

Page 83: Extreme Web Performance for Mobile Device Fluent 2015

remote inspectors

Samsung10%

Android14%

Others4%

Windows Phone3%

Opera 5%

InApp Browser iOS 5%

Safari iOS45%

Chrome15%

Page 84: Extreme Web Performance for Mobile Device Fluent 2015

Measuring

DEMO

Page 85: Extreme Web Performance for Mobile Device Fluent 2015

Proxies / Network sniffers

• Charles Proxy • Fiddler

tools

Image from telerik fiddler

Page 86: Extreme Web Performance for Mobile Device Fluent 2015

Connection simulators

• Network link conditioner (Mac/iOS) • Charles Proxy • Clumsy for Windows • Net Limiter for Windows • SlowyApp for Mac • Chrome Developer Tools

tools

Page 87: Extreme Web Performance for Mobile Device Fluent 2015

html5 apis

Page 88: Extreme Web Performance for Mobile Device Fluent 2015

Navigation Timing API

• window.performance • Timestamps available

html5 apis

Page 89: Extreme Web Performance for Mobile Device Fluent 2015

navigation timing api

Samsung12%

Android*12%

Others4%

Windows Phone3%

Opera 5%

InApp Browser iOS5%

Safari iOS45%

Chrome15%

* Android browser only from 4.0

Page 90: Extreme Web Performance for Mobile Device Fluent 2015
Page 91: Extreme Web Performance for Mobile Device Fluent 2015

Navigation Timing APIhtml5 apis

:)

Page 92: Extreme Web Performance for Mobile Device Fluent 2015

Navigation Timing APIhtml5 apis

:/.1

Page 93: Extreme Web Performance for Mobile Device Fluent 2015

iOS SDK Release Notes for iOS 8.1html5 apis

Page 94: Extreme Web Performance for Mobile Device Fluent 2015

Navigation Timing APIhtml5 apis

DEMO

Page 95: Extreme Web Performance for Mobile Device Fluent 2015

Resource Timing API• Information per resource • Chrome and IE11 only

html5 apis

Page 96: Extreme Web Performance for Mobile Device Fluent 2015

Network information API

• Android Browser, Silk (spec #1) type • BlackBerry 10, old Firefox (spec #2) bandwidth • Firefox, Chrome for Android 38+ (spec #3) type

html5 apis

Page 97: Extreme Web Performance for Mobile Device Fluent 2015

3- tools

- Learn where to test - Measure loading times - Measure responsiveness - HTML5 APIs

Page 98: Extreme Web Performance for Mobile Device Fluent 2015

4- initial loading & perception

Page 99: Extreme Web Performance for Mobile Device Fluent 2015

4- initial loading & perception- 1 second threshold - classic checklist - ATF and the rest - responsive web design - future visits

Page 100: Extreme Web Performance for Mobile Device Fluent 2015
Page 101: Extreme Web Performance for Mobile Device Fluent 2015
Page 102: Extreme Web Performance for Mobile Device Fluent 2015
Page 103: Extreme Web Performance for Mobile Device Fluent 2015
Page 104: Extreme Web Performance for Mobile Device Fluent 2015
Page 105: Extreme Web Performance for Mobile Device Fluent 2015
Page 106: Extreme Web Performance for Mobile Device Fluent 2015

DNS Lookup

Page 107: Extreme Web Performance for Mobile Device Fluent 2015

TCP Connection

Page 108: Extreme Web Performance for Mobile Device Fluent 2015

HTTP Request

Page 109: Extreme Web Performance for Mobile Device Fluent 2015

Server Response

Page 110: Extreme Web Performance for Mobile Device Fluent 2015

RENDERING!

Page 111: Extreme Web Performance for Mobile Device Fluent 2015

RENDERING!

Page 112: Extreme Web Performance for Mobile Device Fluent 2015

What!!?? a page load in 200ms?

(

)

Page 113: Extreme Web Performance for Mobile Device Fluent 2015

No really, we just need the PERCEPTION

Page 114: Extreme Web Performance for Mobile Device Fluent 2015

We need to avoid

Page 115: Extreme Web Performance for Mobile Device Fluent 2015

Basic browser behavior

• Network Fetch • Parsing • Rendering

Page 116: Extreme Web Performance for Mobile Device Fluent 2015

Basic browser behavior

HTML

JS CSS

Page 117: Extreme Web Performance for Mobile Device Fluent 2015

HTML

JS CSSBLOCKS PARSING BLOCKS RENDERING

Page 118: Extreme Web Performance for Mobile Device Fluent 2015
Page 119: Extreme Web Performance for Mobile Device Fluent 2015

= REDIRECTS

Page 120: Extreme Web Performance for Mobile Device Fluent 2015

Redirects

• From 150 to 1000 ms per redirect

Page 121: Extreme Web Performance for Mobile Device Fluent 2015

Redirects

mydomain.com -> m.mydomain.com

Page 122: Extreme Web Performance for Mobile Device Fluent 2015

Redirects

• URL shorteners: t.co, g.co, bit.ly

Page 123: Extreme Web Performance for Mobile Device Fluent 2015

Redirects

DEMO

Page 124: Extreme Web Performance for Mobile Device Fluent 2015
Page 125: Extreme Web Performance for Mobile Device Fluent 2015
Page 126: Extreme Web Performance for Mobile Device Fluent 2015

1. Facebook’s  l.php  2. bit.ly  3. aa.com  4. www.aa.com  5. www.aa.com/HomePage  6. mobile.aa.com  7. mobile.aa.com/HomePage

Page 127: Extreme Web Performance for Mobile Device Fluent 2015
Page 128: Extreme Web Performance for Mobile Device Fluent 2015
Page 129: Extreme Web Performance for Mobile Device Fluent 2015

= APP BANNER

Page 130: Extreme Web Performance for Mobile Device Fluent 2015

= APP SPAM

Page 131: Extreme Web Performance for Mobile Device Fluent 2015

delta.com

• 1-5 seconds delay

Page 132: Extreme Web Performance for Mobile Device Fluent 2015

delta.com

• 1-5 seconds delay

Page 133: Extreme Web Performance for Mobile Device Fluent 2015
Page 134: Extreme Web Performance for Mobile Device Fluent 2015
Page 135: Extreme Web Performance for Mobile Device Fluent 2015

idontwantyourfuckingapp.tumblr.com

Page 136: Extreme Web Performance for Mobile Device Fluent 2015

= APP BANNER

Page 137: Extreme Web Performance for Mobile Device Fluent 2015

The 14K limit

Page 138: Extreme Web Performance for Mobile Device Fluent 2015

The 14K limit

• TCP slow start • Initial congestion window: ~14.6Kb • > 14Kb will create another roundtrip

RTT

Page 139: Extreme Web Performance for Mobile Device Fluent 2015

What!!?? the page contents in 14Kb?

(

)

Page 140: Extreme Web Performance for Mobile Device Fluent 2015

It’s 14Kb HTTP response (so, compressed)

~70Kb

Page 141: Extreme Web Performance for Mobile Device Fluent 2015

We need to separate ABOVE THE FOLD (ATF)

content

Page 142: Extreme Web Performance for Mobile Device Fluent 2015

ATF in 1s

ATF

Page 143: Extreme Web Performance for Mobile Device Fluent 2015

ATF in 1s = 1 RTT

ATF

Page 144: Extreme Web Performance for Mobile Device Fluent 2015

ATF in 1s = 1 RTT ~ 14Kb

ATF

Page 145: Extreme Web Performance for Mobile Device Fluent 2015

ATF in 1s = 1 RTT ~ 14Kb

ATF

HTML + CSS + JavaScript Images?

Page 146: Extreme Web Performance for Mobile Device Fluent 2015

How to embrace ATF in 14Kb?

(

)

Page 147: Extreme Web Performance for Mobile Device Fluent 2015

Avoid JavaScript frameworks

• Embrace Vanilla JS • If you really need them, load them after ATF • Think on alternatives or partial frameworks

ATF

Page 148: Extreme Web Performance for Mobile Device Fluent 2015

Careful with Data URI in CSS

• Images are non-blocking by default • Using Data URI in CSS creates blocking images • Use them only on non-ATF external CSS

ATF

Page 149: Extreme Web Performance for Mobile Device Fluent 2015

Client side rendering

• Careful with client-side frameworks • Try to render the initial view server-side • Render at least a basic view

ATF

Page 150: Extreme Web Performance for Mobile Device Fluent 2015

Client side rendering

• Careful with client-side frameworks • Try to render the initial view server-side • Render at least a basic view

ATF

5x

Page 151: Extreme Web Performance for Mobile Device Fluent 2015

Web Fonts• Blocks text rendering • Fonts are bigger than 14Kb • Remove characters • Simplify glyphs • Don’t use it on ATF

ATF

Page 152: Extreme Web Performance for Mobile Device Fluent 2015

Responsive Web Design

Page 153: Extreme Web Performance for Mobile Device Fluent 2015

Responsive Web Design

• Media queries block rendering (all of them) • ATF content on mobile is unique

Page 154: Extreme Web Performance for Mobile Device Fluent 2015

DON’T rely on RWD techniques only

for first view

Page 155: Extreme Web Performance for Mobile Device Fluent 2015

RESPONSIVE WEB DESIGN is the future

Page 156: Extreme Web Performance for Mobile Device Fluent 2015

We are not saying go m.*

Page 157: Extreme Web Performance for Mobile Device Fluent 2015

Responsive Web Design

• Using same URL for mobile/desktop still a good a idea • Mix it with RESS / adaptive web design • Load media queries CSS async • Use server-side libraries to decide to send ATF only • WURFL or DeviceAtlas

Page 158: Extreme Web Performance for Mobile Device Fluent 2015

After ATF is ready

• Load rest of your content • Gain experience while rendering ATF: current performance, screen density, bandwidth • Make decisions: HD/SD

Page 159: Extreme Web Performance for Mobile Device Fluent 2015

Async scripts

<script async src=""></script> HTML5

Page 160: Extreme Web Performance for Mobile Device Fluent 2015

Defer non-ATF CSS

• No defer or async attributes (yet) • Inject <link> after rendering • load, requestAnimationFrame

Page 161: Extreme Web Performance for Mobile Device Fluent 2015

Speed future visits

• Be cache friendly • Use Application Cache for ATF content • Create a custom cache

Page 162: Extreme Web Performance for Mobile Device Fluent 2015

4- initial loading & perception

- ATF in 1s (illusion) - No redirects, GZip, no scripts - Only ATF CSS, careful with fonts - Defer anything else

Page 163: Extreme Web Performance for Mobile Device Fluent 2015

5- responsiveness & experience

Page 164: Extreme Web Performance for Mobile Device Fluent 2015

4- responsiveness & experience- experience - consistent frame rate - immediate feedback - scrolling - your new enemy

Page 165: Extreme Web Performance for Mobile Device Fluent 2015

Optimize your content for mobile

experience

Page 166: Extreme Web Performance for Mobile Device Fluent 2015
Page 167: Extreme Web Performance for Mobile Device Fluent 2015

Keep framerate high and consistent

• Keep framerate high and consistent • Avoid DOM manipulations in loops/scroll • Careful promoting GPU layers

consistent fps

Page 168: Extreme Web Performance for Mobile Device Fluent 2015

remember 100ms immediate feedback?

Page 169: Extreme Web Performance for Mobile Device Fluent 2015

Immediate feedback

• The 300ms delay

• mobile viewport (“user-scalable=no” on some browsers) • FastClick solution

Page 170: Extreme Web Performance for Mobile Device Fluent 2015

Immediate feedback

• Mobile Viewport on Chrome

<meta name=viewport content="width=device-width">

HTML

Page 171: Extreme Web Performance for Mobile Device Fluent 2015

Immediate feedback

• Mobile Fixed Viewport on IE <meta name=viewport content="width=device-width, user-scalable=no" >

HTML

Page 172: Extreme Web Performance for Mobile Device Fluent 2015

Immediate feedback

• CSS on IE html { -ms-touch-action: manipulation; touch-action: manipulation; }

CSS

Page 173: Extreme Web Performance for Mobile Device Fluent 2015

Distract the user

Page 174: Extreme Web Performance for Mobile Device Fluent 2015

Storage for immediate feedback

• web storage vs web sql vs indexeddb • think about async vs sync • Finally IndexedDB on iOS 8!

Page 175: Extreme Web Performance for Mobile Device Fluent 2015

Scrolling

• avoid re-painting • use touch overflow for momentum • don’t use JavaScript scrollers

Page 176: Extreme Web Performance for Mobile Device Fluent 2015

Your new enemy

Page 177: Extreme Web Performance for Mobile Device Fluent 2015

NOT THE USER

Page 178: Extreme Web Performance for Mobile Device Fluent 2015

YOUR DESIGNER

Page 179: Extreme Web Performance for Mobile Device Fluent 2015

Careful with some design features

• GPU vs CPU repaint • Important on scroll, transitions & animations

Page 180: Extreme Web Performance for Mobile Device Fluent 2015

Careful with some design features

• Transforms: translate, scale, rotate and opacity GPU • border-radius, gradients, shadows, filters CPU repaint

Page 181: Extreme Web Performance for Mobile Device Fluent 2015

5- responsiveness & experience- 100s feedback - Consistent fps - Avoid CPU repaints - Embrace GPU smartly - Profile & test

Page 182: Extreme Web Performance for Mobile Device Fluent 2015

Picture from Simon Howden freedigitalphotos.net!

Picture from Simon Howden freedigitalphotos.net!

uf! we've covered a lot!

Page 183: Extreme Web Performance for Mobile Device Fluent 2015

1- Mobile Web today 2- Mobile Performance 3- Tools 4- Initial load & perception 5- Responsiveness & experience

Page 184: Extreme Web Performance for Mobile Device Fluent 2015

Slides, links and tests firtman.github.io/fluent

Page 185: Extreme Web Performance for Mobile Device Fluent 2015

final thoughts

- measure and profile on the real world - don’t redirect, reduce requests - atf content in 1s, defer the rest - be simple, be aggressive

Page 186: Extreme Web Performance for Mobile Device Fluent 2015

you can reach a good experience

Pictures)from)freedigitalphotos.net)

[email protected]@firt

firt.mobi/pmw firt.mobi/mh5

Book signing: Tue 18.00

Office Hours: Tue 14.15

50% OFF!