Slide 1

Slide 1 text

Good Morning.

Slide 2

Slide 2 text

Matthew Crist @matthewcrist

Slide 3

Slide 3 text

Boston /Bähston/

Slide 4

Slide 4 text

Customers Hate Slow Websites

Slide 5

Slide 5 text

☻ ☻ ☻ ☻ ☻ ☻ 2% of them bounce after 1s ☻ ☻ ☻

Slide 6

Slide 6 text

☻ ☻ ☻ ☻ ☻ ☻ 40% of them bounce after 2s

Slide 7

Slide 7 text

☻ ☻ ☻ ☻ ☻ 57% bounce after 3s

Slide 8

Slide 8 text

Customers show NO MERCY for slow websites

Slide 9

Slide 9 text

Loses 1% of sales per 100ms delay

Slide 10

Slide 10 text

Loses 5%-9% of traffic per 400ms delay

Slide 11

Slide 11 text

Loses 3% of traffic per 500ms delay

Slide 12

Slide 12 text

☻ ☻ 85% of mobile users expect same response time as desktop

Slide 13

Slide 13 text

An overly simplified graphic of a non-mobile web request

Slide 14

Slide 14 text

An overly simplified of a desktop web request DNS

Slide 15

Slide 15 text

An overly simplified of a desktop web request DNS

Slide 16

Slide 16 text

These requests can take up to 200ms You’ll never get this back. 1 second

Slide 17

Slide 17 text

An overly simplified of a desktop web request DNS Server

Slide 18

Slide 18 text

An overly simplified of a desktop web request DNS Server

Slide 19

Slide 19 text

An overly simplified of a desktop web request DNS Server

Slide 20

Slide 20 text

An overly simplified graphic of a mobile web request

Slide 21

Slide 21 text

An overly simplified of a desktop web request The Tower

Slide 22

Slide 22 text

An overly simplified of a desktop web request The Tower

Slide 23

Slide 23 text

All your latency belongs to the tower 1 second 3.5seconds A 3g connection A 4g connection

Slide 24

Slide 24 text

An overly simplified of a desktop web request The Tower DNS

Slide 25

Slide 25 text

An overly simplified of a desktop web request The Tower DNS

Slide 26

Slide 26 text

These requests can take up to 200ms You’ll never get this back. 1 second

Slide 27

Slide 27 text

An overly simplified of a desktop web request The Tower DNS Server

Slide 28

Slide 28 text

An overly simplified of a desktop web request The Tower DNS Server

Slide 29

Slide 29 text

An overly simplified of a desktop web request The Tower DNS Server

Slide 30

Slide 30 text

Average page is 1.4mb

Slide 31

Slide 31 text

jQuery 1 second loads and processes in about 139ms

Slide 32

Slide 32 text

Zepto 1 second loads and processes in about 51ms

Slide 33

Slide 33 text

Bootstrap 1 second loads and processes in about 600ms Don’t forget jQuery

Slide 34

Slide 34 text

Choose your tax 1 second jQuery Zepto Nothing

Slide 35

Slide 35 text

These examples were performed under optimal conditions.

Slide 36

Slide 36 text

The “Golden Second” is aspirational.

Slide 37

Slide 37 text

We can always try our hardest and do our best.

Slide 38

Slide 38 text

How?

Slide 39

Slide 39 text

Lose 10ms with this one weird server trick.

Slide 40

Slide 40 text

Combine It,

Slide 41

Slide 41 text

CSS CSS CSS CSS CSS CSS CSS CSS CSS CSS CSS CSS CSS Combine many CSS files into one “compressed”.

Slide 42

Slide 42 text

JS JS JS JS JS JS JS JS JS JS JS JS JS Develop a build process for JS to compress & minify

Slide 43

Slide 43 text

IMG IMG IMG IMG IMG IMG IMG IMG IMG IMG IMG IMG IMG Combine images into sprites where possible.

Slide 44

Slide 44 text

Combine It, Minimize It,

Slide 45

Slide 45 text

GZIP it, Combine It, Minimize It,

Slide 46

Slide 46 text

GZIP it, Combine It, Minimize It, CDN it,

Slide 47

Slide 47 text

{ ! background-image: url(data:image/jpeg;base64,/9j/4AAQSkZJRgABAAEAYABgAAD// gAfTEVBRCBUZWNobm9sb2dpZXMgSW5jLiBWMS4wMQD/ 2wBDAAICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgMDAgIDAgICAwQDAwMDBAQEAgMEBAQEBAMEBAP/ 2wBDAQICAgICAgICAgIDAgICAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwP/ wgARCAEJAQkDAREAAhEBAxEB/8QAHAAAAQUBAQEAAAAAAAAAAAAAAgEDBAUGAAcI/8QAGQEAAwEBAQAAAAAAAAAAAAAAAAECAwQF/ 9oADAMBAAIQAxAAAAHFeB6Hi++W8U2fPs7LJ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nTo47mtMXjhl5nQiK4BBA4FDP6y5I4FPRU0pBnJC UDSLfFW5s4UoEwgNU27zWm7FUZITU93om6hxQvmr3xaPNy8acNFDgdAwMPGOvE9B0GxWQTnKo5S0qHDSYhxW4Ag4y8IkvWpe8mthdF M1EmoZEqczrxQ3yVKJ0O9zu0zcibnmkht1HkvqYPBJFhyNKEyqZFGiKJPT46yCpo2GSyZtTOnOlTtl0uV1OrRqZoM4tGUmuXa8tcY1 pLDb83PzT6bU6xi0KZ7ueYptxYSlsglzUcJeczwmzq2KA3HEZNiEgmhD6qevys +jJTcxLbRMq5x9Yk5qwZpIlOSnTTjDQ4VIVF0RdTMgXllTrhzZbSBhWCbI69uIOUJVM4ZisG/r +zHlfE9nsiPfM38eiqxyEloMIkzKcKakhtEoFkk9Kt5i3F4fR7aOxkRLAwXSqGFQBDQHAnBwvWKf0JqfH4vP5TAfU6Pm6HzsZEspUW JL4G2iYomIEnY725ONoF7RjgiSNozUGjTpRwRyRCOWKYOsZ9N2aiz5jF5fM +rhJR57DVUCodBlBuHBkNkcqAw6Y9J3qcS0GmFjggS82FFJoUVA2gliIcqRyph6z9UNlD+VB5Op+kh Your CSS File Some images do well as DATA-URI to help reduce HTTP requests.

Slide 48

Slide 48 text

GZIP it, Combine It, Minimize It, CDN it, Cache it.

Slide 49

Slide 49 text

CSS Blocks until loaded

Slide 50

Slide 50 text

CSS JS Does too

Slide 51

Slide 51 text

CSS JS HTML HTML HTML HTML

Slide 52

Slide 52 text

Render fast, render often.

Slide 53

Slide 53 text

Limit blocking items early in the DOM.

Slide 54

Slide 54 text

Watch the dev tools

Slide 55

Slide 55 text

Reduce CSS,

Slide 56

Slide 56 text

Reduce CSS, Offload to the server,

Slide 57

Slide 57 text

With media queries, we can right size images, CSS, Javascript. RESS

Slide 58

Slide 58 text

Reduce CSS, Offload to the server, Unblock Javascript,

Slide 59

Slide 59 text

head.js("/path/to/jquery.js", function() { // all done }); Your Javascript File Head.js

Slide 60

Slide 60 text

$LAB.script("jquery.js").wait() .script("jquery.ui.js") Your Javascript File Lab.js

Slide 61

Slide 61 text

yepnope([ { test : SomeJSTestHere, yep : ['/js/javascriptYouNeed.js', '/css/CSSYouNeed.css'], nope : ['/js/maybeAPolyfillOrSomethingAlongThoseLines.js', '/css/CrayCSS.css'] } ]); Your Javascript File YepNope.js

Slide 62

Slide 62 text

Your Javascript File HTML5 Firefox 3.6+, IE 10+, Chrome 2+, Safari 5+, iOS 5+, Android 3+

Slide 63

Slide 63 text

Reduce CSS, Offload to the server, Unblock Javascript, Question everything.

Slide 64

Slide 64 text

Do I really need ___________ ? Bootstrap

Slide 65

Slide 65 text

Do I really need ___________ ? jQuery

Slide 66

Slide 66 text

Do I really need ___________ ? Ember

Slide 67

Slide 67 text

Do I really need ___________ ? Backbone

Slide 68

Slide 68 text

What’s the least amount needed to paint above the fold? The fold

Slide 69

Slide 69 text

The fold hides all slowness.

Slide 70

Slide 70 text

It’s the same image Why not load an image once?

Slide 71

Slide 71 text

Is responsive design slower?

Slide 72

Slide 72 text

thepaintdrop.com ... 492kb

Slide 73

Slide 73 text

status.heroku.com ... 190kb

Slide 74

Slide 74 text

trello.com ... ~400kb

Slide 75

Slide 75 text

instragram ... ~600kb

Slide 76

Slide 76 text

These are first load problems.

Slide 77

Slide 77 text

Delays cause user confusion and cost us revenue. Down with the spinners.

Slide 78

Slide 78 text

The Lobster Parable Ladies and gentlemen: the story you are about to hear is true. Only the names have been changed...

Slide 79

Slide 79 text

No content

Slide 80

Slide 80 text

Iowa

Slide 81

Slide 81 text

No content

Slide 82

Slide 82 text

No content

Slide 83

Slide 83 text

If there is a delay, animate or provide feedback.

Slide 84

Slide 84 text

Let’s talk about the client side.

Slide 85

Slide 85 text

Client side is slow on first load 1 second

Slide 86

Slide 86 text

If implemented poorly, can be slow subsequently.

Slide 87

Slide 87 text

Turbolinks

Slide 88

Slide 88 text

Turbolinks noun A ruby gem for speeding up your internet pages

Slide 89

Slide 89 text

Javascript + pushState = Turbo Boost Also known as PJAX

Slide 90

Slide 90 text

How to use it gem 'turbolinks' Gemfile //= require turbolinks application.js

Slide 91

Slide 91 text

Use these as well... page:fetch // Fires when starting to fetch page page:receive // Fires when page received not parsed page:change // Fires when page is parsed and changed page:load // Fires when all done Turbolinks Events

Slide 92

Slide 92 text

Built in cache page:change // Fires when page is changed from cache page:restore // Fires when all done Turbolinks Cache Events Turbolinks saves last 10 pages

Slide 93

Slide 93 text

Opt Out
Screw you Turbolinks

Slide 94

Slide 94 text

jQuery Turbolinks gem 'jquery-turbolinks' Gemfile //= require turbolinks application.js Helps bind existing apps to Turbolinks

Slide 95

Slide 95 text

Your HTML File Prefetch Your DNS Chrome, Firefox 3.5+, Safari 5+, Opera, IE 10 Lose 50ms

Slide 96

Slide 96 text

Your HTML File Prefetch Everything Else Chrome, Firefox 3.5+, Safari 5+, Opera, IE 10 Lose 50ms

Slide 97

Slide 97 text

Tools should make us more efficient, otherwise it’s not a tool.

Slide 98

Slide 98 text

fin.