the shape of speed

120

Upload: oliver-tse

Post on 20-Feb-2017

344 views

Category:

Software


0 download

TRANSCRIPT

Page 1: The Shape of Speed
Page 2: The Shape of Speed

The Shape of Speed

By Oliver TseJanuary 6, 2016

Page 3: The Shape of Speed

Who Am I? Oliver Tse

Web Developer

Page 4: The Shape of Speed

Main Objective

Page 5: The Shape of Speed

Seriously…

Page 6: The Shape of Speed

Broader, when you walk out… grok ● “Render first. JavaScript second.”● Reduce render time and create a better experience.● When, what and how much you render is very important

Page 7: The Shape of Speed

What we’ll talk about1. All rendering2. Chart parts3. Flat4. Cache is king5. JavaScript6. Fix-a-flat7. Comparing

Page 8: The Shape of Speed

1All rendering

Page 9: The Shape of Speed
Page 10: The Shape of Speed
Page 11: The Shape of Speed

Performance is how much, how fast and when a page renders

Page 12: The Shape of Speed

It began with a man named Pat

Page 13: The Shape of Speed

2008Patrick Meenan ( and AOL ) give us Webpagetest

Page 14: The Shape of Speed
Page 15: The Shape of Speed
Page 16: The Shape of Speed
Page 17: The Shape of Speed
Page 18: The Shape of Speed

Webpagetest info/parameters● Synthetic testing● Only looks at above-the-fold● Private instance of webpagetest.org● 5 “first time” runs ● Chrome ( latest )● Cable 5/1 mbps 28ms RTT

Page 19: The Shape of Speed

2Chart parts

Page 20: The Shape of Speed

Yahoo!

Page 21: The Shape of Speed

PlateausValleysCliffsHills

Page 22: The Shape of Speed
Page 23: The Shape of Speed

Plateaus

Page 24: The Shape of Speed

flat areas

Page 25: The Shape of Speed

They occur because of activities in the main thread and assets downloading

Page 26: The Shape of Speed

no rendering changes occurs at plateausimportant...

Page 27: The Shape of Speed
Page 28: The Shape of Speed

Valleys

Page 29: The Shape of Speed

dips

Page 30: The Shape of Speed

What was there is visually no more

Page 31: The Shape of Speed

Now you see it

Page 32: The Shape of Speed

Now you don’t!

Page 33: The Shape of Speed

what you just saw was reflow*

*Bad

Page 34: The Shape of Speed

Cliffs

Page 35: The Shape of Speed

steep. Tall.

Page 36: The Shape of Speed

Follows a plateau.fast render

Page 37: The Shape of Speed
Page 38: The Shape of Speed

Hills

Page 39: The Shape of Speed

Progressive rendering

Page 40: The Shape of Speed

Small partial renderingsimages, content animating in

Page 41: The Shape of Speed
Page 42: The Shape of Speed

To go and feel fastAvoid valleys, long plateaus.

Page 43: The Shape of Speed

3Flat

Page 44: The Shape of Speed

“Plateaus occur because of activities in the main thread and assets downloading”

Page 45: The Shape of Speed
Page 46: The Shape of Speed
Page 47: The Shape of Speed

Before first render, Jobs gets assets...● 1 HTML● 2 images● 2 stylesheets● 12 JavaScript files

Page 48: The Shape of Speed
Page 49: The Shape of Speed
Page 50: The Shape of Speed

What about the main thread?

Page 51: The Shape of Speed
Page 52: The Shape of Speed
Page 53: The Shape of Speed

First plateau is about downloading

Page 54: The Shape of Speed

Subsequent plateau

Page 55: The Shape of Speed
Page 56: The Shape of Speed
Page 57: The Shape of Speed
Page 58: The Shape of Speed
Page 59: The Shape of Speed
Page 60: The Shape of Speed
Page 61: The Shape of Speed

For Jobs, it’s JavaScript

Page 62: The Shape of Speed
Page 63: The Shape of Speed
Page 64: The Shape of Speed

But subsequent plateaus aren’t always about JavaScript

Page 65: The Shape of Speed
Page 66: The Shape of Speed
Page 67: The Shape of Speed
Page 68: The Shape of Speed
Page 69: The Shape of Speed
Page 70: The Shape of Speed

Here, images impact plateau

Page 71: The Shape of Speed
Page 72: The Shape of Speed
Page 73: The Shape of Speed

4.Cache is king

Page 74: The Shape of Speed
Page 75: The Shape of Speed
Page 76: The Shape of Speed
Page 77: The Shape of Speed

Cached page is always fasterfor first render

Page 78: The Shape of Speed

Fewer requestsShorter first plateau

Page 79: The Shape of Speed

For Jobs and the Engineering Blog,80% and 68% fewer requests

Page 80: The Shape of Speed

5.JavaScript

Page 81: The Shape of Speed
Page 82: The Shape of Speed
Page 83: The Shape of Speed
Page 84: The Shape of Speed
Page 85: The Shape of Speed
Page 86: The Shape of Speed
Page 87: The Shape of Speed
Page 88: The Shape of Speed
Page 89: The Shape of Speed

When you have JavaScript dependencies,caching won’t shorten the second plateau

Page 90: The Shape of Speed

So, what do we do?

Page 91: The Shape of Speed

“Time sliced rendering”- Garris Shipon

Page 92: The Shape of Speed

Group blocks of work into small chunks of time

Page 93: The Shape of Speed

● Optimistic UI Pattern● Google’s RAIL’s “Idle”

Page 94: The Shape of Speed

“Whenever the user takes an action, you need to first update your UI to make things look fast, then send a request to the

server to do that modification on the real database. ” - Optimistic UI Pattern

Page 95: The Shape of Speed

Google’s RAIL

Page 96: The Shape of Speed

“Complete that work in 50ms” or less-Google RAIL

Page 97: The Shape of Speed

Benefits● Responsive UI● Progressive rendering

Page 98: The Shape of Speed
Page 99: The Shape of Speed

“Render first. JavaScript second.”-Steve Souders

Page 100: The Shape of Speed

6.Fix-a-flat

Page 101: The Shape of Speed

PYMK

Page 102: The Shape of Speed
Page 103: The Shape of Speed
Page 104: The Shape of Speed
Page 105: The Shape of Speed
Page 106: The Shape of Speed

Homepage

Page 107: The Shape of Speed
Page 108: The Shape of Speed
Page 109: The Shape of Speed
Page 110: The Shape of Speed

Stuff that’ll get hills● Animations● Deferred images● Progressive images● Time-sliced rendering

Page 111: The Shape of Speed

Comparing

Page 112: The Shape of Speed

browsers

Page 113: The Shape of Speed
Page 114: The Shape of Speed

versions

Page 115: The Shape of Speed
Page 116: The Shape of Speed

internationals

Page 117: The Shape of Speed
Page 118: The Shape of Speed

Thank you!