Lots of ways to speed up your site

176
WAYS TO MAKE YOUR SITE FASTER THE SITE SPEED DOWNLOAD

Transcript of Lots of ways to speed up your site

Page 1: Lots of ways to speed up your site

@portentint

WAYS TO MAKE YOUR SITE FASTER THE SITE SPEED DOWNLOAD

Page 2: Lots of ways to speed up your site

@portentint

hp://portent.co/speedy-sites

Page 3: Lots of ways to speed up your site

@portentint

SITE SPEED IS A LITTLE SCARY

WHAT THE HELL IS TTFB?!!!

Page 4: Lots of ways to speed up your site

@portentint

WE’LL WALK THROUGH IT

well, that’s a relief

Page 5: Lots of ways to speed up your site

@portentint

I’ll explain relative difficul, impact & when to use each technique

Page 6: Lots of ways to speed up your site

@portentint

Ratings Scale

difficul: impact:

Page 7: Lots of ways to speed up your site

@portentint

These are just the techniques I’ve found to be the biggest wins

Page 8: Lots of ways to speed up your site

@portentint

WHY?

Page 9: Lots of ways to speed up your site

@portentint

HERE’S THE THING

FASTER IS BETTER

Page 10: Lots of ways to speed up your site

@portentint

HERE’S THE THING

MOSTLY.

heh. Oops.

Page 11: Lots of ways to speed up your site

@portentint

must… deliver…

Page 12: Lots of ways to speed up your site

@portentint

HERE’S THE THING

Page 13: Lots of ways to speed up your site

@portentint

HERE’S THE THING

Page 14: Lots of ways to speed up your site

@portentint

HERE’S THE THING

Page 15: Lots of ways to speed up your site

@portentint

WHY?

$-

$10.00

$20.00

$30.00

1 2 3 4 5 6 7 8 9 Load time (seconds)

Page Value vs. Load Time

Page 16: Lots of ways to speed up your site

@portentint

WHY?

$-

$10.00

$20.00

$30.00

1 2 3 4 5 6 7 8 9 Load time (seconds)

Page Value vs. Load Time

WHY NOT?!!!!

Page 17: Lots of ways to speed up your site

@portentint

THREE BOTTLENECKS

Page 18: Lots of ways to speed up your site

@portentint

SERVING

Page 19: Lots of ways to speed up your site

@portentint

TRANSMISSION

Page 20: Lots of ways to speed up your site

@portentint

RENDERING

Page 21: Lots of ways to speed up your site

@portentint

DIAGNOSTIC TOOLS

Page 22: Lots of ways to speed up your site

@portentint

GOOGLE PAGE SPEED INSIGHTS BASIC ANALYSIS

Page 23: Lots of ways to speed up your site

@portentint

Mostly transmission diagnostics

Page 24: Lots of ways to speed up your site

@portentint

developers.google.com/speed/pagespeed/insights/

Page 25: Lots of ways to speed up your site

@portentint

YSLOW READ YOUR WEB SITE’S MIND

Page 26: Lots of ways to speed up your site

@portentint

Powerful

Page 27: Lots of ways to speed up your site

@portentint

Less intuitive

Page 28: Lots of ways to speed up your site

@portentint

yslow.org

Page 29: Lots of ways to speed up your site

@portentint

WEBPAGETEST.ORG A HAPPY MEDIUM

Page 30: Lots of ways to speed up your site

@portentint

Captures many important stats Hard-to-read HAR

Page 31: Lots of ways to speed up your site

@portentint

WHY YOU CAN’T TRUST TOOLS

Page 32: Lots of ways to speed up your site

@portentint

Webpagetest.org: > 8 seconds

Page 33: Lots of ways to speed up your site

@portentint

Pingdom: 1.67 seconds

Page 34: Lots of ways to speed up your site

@portentint

Reali

Page 35: Lots of ways to speed up your site

@portentint

USE HAR SITE SPEED SUPERPOWERS

Page 36: Lots of ways to speed up your site

@portentint

HAR: A direct, step-by-step view of site load & rendering

Page 37: Lots of ways to speed up your site

@portentint

Page 38: Lots of ways to speed up your site

@portentint

Page 39: Lots of ways to speed up your site

@portentint

Page 40: Lots of ways to speed up your site

@portentint

Page 41: Lots of ways to speed up your site

@portentint

DIAGNOSING BOTTLENECKS & SPEEDING UP YOUR SITE

Page 42: Lots of ways to speed up your site

@portentint

TRANSMISSION

Page 43: Lots of ways to speed up your site

@portentint

WHY START WITH TRANSMISSION? IT’S GOT THE EASIEST WINS

Page 44: Lots of ways to speed up your site

@portentint

Blue = Download time

It’s about bandwidth

Page 45: Lots of ways to speed up your site

@portentint

Image Compression

difficul: impact:

Page 46: Lots of ways to speed up your site

@portentint

Google PageSpeed

Page 47: Lots of ways to speed up your site

@portentint

HAR

Page 48: Lots of ways to speed up your site

@portentint

JPG format, 100% quali, 800 x 540: 400kb

Page 49: Lots of ways to speed up your site

@portentint

JPG format, 90% quali, 800 x 540: 217kb

Page 50: Lots of ways to speed up your site

@portentint

JPG format, 80% quali, 800 x 540: 100kb

Page 51: Lots of ways to speed up your site

@portentint

JPG format, 60% quali, 800 x 540: 67kb

Page 52: Lots of ways to speed up your site

@portentint

Page Speed Insights…

Page 53: Lots of ways to speed up your site

@portentint

…But it only does png

Page 54: Lots of ways to speed up your site

@portentint

Compression tools Imageoptim (Mac) Caesium (PC) Fireworks/Photoshop

Page 55: Lots of ways to speed up your site

@portentint

Start at 60% JPG and work your way up/down

Page 56: Lots of ways to speed up your site

@portentint

Start at 128 color PNG

Page 57: Lots of ways to speed up your site

@portentint

USE WHEN WHY THE HELL NOT?!

Page 58: Lots of ways to speed up your site

@portentint

Use the right image format

difficul: impact:

Page 59: Lots of ways to speed up your site

@portentint

PNG format, 800 x 540: 1,000kb

Page 60: Lots of ways to speed up your site

@portentint

JPG format, 100% quali: 60kb

Page 61: Lots of ways to speed up your site

@portentint

PNG format, 32m color: 13kb

Page 62: Lots of ways to speed up your site

@portentint

PNG format, 256k color: 8kb

Page 63: Lots of ways to speed up your site

@portentint

USE WHEN WHY THE HELL NOT?!

Page 64: Lots of ways to speed up your site

@portentint

Minification

difficul: impact:

Page 65: Lots of ways to speed up your site

@portentint

Not minified: 260kb

Page 66: Lots of ways to speed up your site

@portentint

Minified: 32kb

Page 67: Lots of ways to speed up your site

@portentint

Google PageSpeed

Page 68: Lots of ways to speed up your site

@portentint

Use .MIN.JS version of javascript libraries

Page 69: Lots of ways to speed up your site

@portentint

jscompress.com

Page 70: Lots of ways to speed up your site

@portentint

cssminifier.com

Page 71: Lots of ways to speed up your site

@portentint

HTML, too

Page 72: Lots of ways to speed up your site

@portentint

USE WHEN Always

Page 73: Lots of ways to speed up your site

@portentint

HTTP compression

difficul: impact:

Page 74: Lots of ways to speed up your site

@portentint

Lossless compression of HTML, javascript, css, other files

Page 75: Lots of ways to speed up your site

@portentint

Hey, thanks! I’ll extract it here.

I’m going to compress these files for you so they arrive more

quickly.

Page 76: Lots of ways to speed up your site

@portentint

CHECKGZIPCOMPRESSION.COM

Page 77: Lots of ways to speed up your site

@portentint

Google PageSpeed

Page 78: Lots of ways to speed up your site

@portentint

Apache mod_deflate

Page 79: Lots of ways to speed up your site

@portentint

nginx ngx_hp_gzip_module

Page 80: Lots of ways to speed up your site

@portentint

IIS Click the checkbox

Page 81: Lots of ways to speed up your site

@portentint

Not always possible with 3rd-par scripts

Page 82: Lots of ways to speed up your site

@portentint

NOT OVER SSL unless you really know what you’re doing

Page 83: Lots of ways to speed up your site

@portentint

USE WHEN Any non-encrypted

Page 84: Lots of ways to speed up your site

@portentint

Expires Headers

difficul: impact:

Page 85: Lots of ways to speed up your site

@portentint

this file doesn’t change

that often.

ok, i’ll save it to my hard drive.

Page 86: Lots of ways to speed up your site

@portentint

Google PageSpeed

Page 87: Lots of ways to speed up your site

@portentint

Not possible w/ 3rd-par scripts

Page 88: Lots of ways to speed up your site

@portentint

Apache mod_expires

Page 89: Lots of ways to speed up your site

@portentint

nginx ngx_hp_headers_module

Page 90: Lots of ways to speed up your site

@portentint

IIS clientCache or hpExpires or …?

Page 91: Lots of ways to speed up your site

@portentint

USE WHEN Site uses many static files

Page 92: Lots of ways to speed up your site

@portentint

HERE’S THE THING TEST.

my bad.

Page 93: Lots of ways to speed up your site

@portentint

RENDERING

Page 94: Lots of ways to speed up your site

@portentint

It’s about browser performance How quickly can a browser ‘draw’ this page?

Page 95: Lots of ways to speed up your site

@portentint

Webpagetest.org

Page 96: Lots of ways to speed up your site

@portentint

This line

HAR view

This number

Page 97: Lots of ways to speed up your site

@portentint

APPARENT RENDER TIME

MEASURED RENDER TIME

Page 98: Lots of ways to speed up your site

@portentint

Load order

difficul: impact:

Page 99: Lots of ways to speed up your site

@portentint

CSS first. Javascript last.

Page 100: Lots of ways to speed up your site

@portentint

<script src=“script.js” defer>

Load in parallel, don’t block

Page 101: Lots of ways to speed up your site

@portentint

<script src=“script.js” async>

Load in parallel, execute as soon as possible

Page 102: Lots of ways to speed up your site

@portentint

Tag managers…?

Page 103: Lots of ways to speed up your site

@portentint

Google PageSpeed

Page 104: Lots of ways to speed up your site

@portentint

HAR

Page 105: Lots of ways to speed up your site

@portentint

May break 3rd-par javascript

Page 106: Lots of ways to speed up your site

@portentint

USE WHEN You can

Page 107: Lots of ways to speed up your site

@portentint

Parallel downloads

difficul: impact:

Page 108: Lots of ways to speed up your site

@portentint

3 different subdomains

Page 109: Lots of ways to speed up your site

@portentint

Parallel load

Page 110: Lots of ways to speed up your site

@portentint

USE WHEN You can use multiple subdomains

You use a CDN

Page 111: Lots of ways to speed up your site

@portentint

Optimizing HTML

difficul: impact:

Page 112: Lots of ways to speed up your site

@portentint

35,000 lines of code Render time: 1.5s

html: 900kb

Page 113: Lots of ways to speed up your site

@portentint

why?

Page 114: Lots of ways to speed up your site

@portentint

Put in .css instead

Page 115: Lots of ways to speed up your site

@portentint

Much beer

Page 116: Lots of ways to speed up your site

@portentint

Minified html

Page 117: Lots of ways to speed up your site

@portentint

DOM elements (yslow)

Page 118: Lots of ways to speed up your site

@portentint

At least get rid of the white space

Page 119: Lots of ways to speed up your site

@portentint

USE WHEN Always

Page 120: Lots of ways to speed up your site

@portentint

Lazy loading

difficul: impact:

Page 121: Lots of ways to speed up your site

@portentint

Image loads when I scroll to here

Page 122: Lots of ways to speed up your site

@portentint

hp://portent.co/load-lazy

Page 123: Lots of ways to speed up your site

@portentint

USE WHEN You have below-the-fold images

You have a gallery

Page 124: Lots of ways to speed up your site

@portentint

DNS prefetch

difficul: impact:

Page 125: Lots of ways to speed up your site

@portentint

HAR

Page 126: Lots of ways to speed up your site

@portentint

<link rel="dns-prefetch" href="//domainname.com" /> <link rel=“dns-prefetch” href=“https://api.twitter.com” />

Page 127: Lots of ways to speed up your site

@portentint

Prefetch/Prerender

difficul: impact:

Page 128: Lots of ways to speed up your site

@portentint

You go to this page a lot.

I’m going to get it ready ahead of

time.

Page 129: Lots of ways to speed up your site

@portentint

Most popular page prerendered

Page 130: Lots of ways to speed up your site

@portentint

Page 131: Lots of ways to speed up your site

@portentint

<link rel="prerender" href=”images/kittens.jpg">

Load file in advance

Page 132: Lots of ways to speed up your site

@portentint

<link rel=”prefetch" href="http://my-site.com/bar.html">

Load & render page in advance

Page 133: Lots of ways to speed up your site

@portentint

USE WHEN You know certain pages dominate

Page 134: Lots of ways to speed up your site

@portentint

HERE’S THE THING TEST!!!

d’oh

Page 135: Lots of ways to speed up your site

@portentint

SERVING

Page 136: Lots of ways to speed up your site

@portentint

Nerds required

yeah baby

Page 137: Lots of ways to speed up your site

@portentint

TTFB: Time To First Byte

Page 138: Lots of ways to speed up your site

@portentint

Google PageSpeed

Page 139: Lots of ways to speed up your site

@portentint

HAR

Page 140: Lots of ways to speed up your site

@portentint

Time to First Byte (TTFB) should not > 500ms

Page 141: Lots of ways to speed up your site

@portentint

But <250ms is beer

Page 142: Lots of ways to speed up your site

@portentint

CDN

difficul: impact:

Page 143: Lots of ways to speed up your site

@portentint

No CDN

hellloooooo

Page 144: Lots of ways to speed up your site

@portentint

CDN

Page 145: Lots of ways to speed up your site

@portentint

A lot of work, but also helps with hp compression, parallel loading, cookieless delivery, expires headers

Page 146: Lots of ways to speed up your site

@portentint

USE WHEN You can

Page 147: Lots of ways to speed up your site

@portentint

disk & query caching

difficul: impact:

Page 148: Lots of ways to speed up your site

@portentint

STORED ON DISK

Page 149: Lots of ways to speed up your site

@portentint

That’s a long time. Are you using disk caching?

Page 150: Lots of ways to speed up your site

@portentint

Stalled may indicate a page generation boleneck. Use disk/query caching

Page 151: Lots of ways to speed up your site

@portentint

USE WHEN …

Page 152: Lots of ways to speed up your site

@portentint

keep-alive

difficul: impact:

Page 153: Lots of ways to speed up your site

@portentint

No keep-alive

Sure!may i have

index.html?

Page 154: Lots of ways to speed up your site

@portentint

No keep-alive

Sure!may i have

index.html?

ok! can I have styles.css? uh, ok

Page 155: Lots of ways to speed up your site

@portentint

No keep-alive

Sure!may i have

index.html?

ok! can I have styles.css? uh, okthanks! can i have

jquery.js?

Page 156: Lots of ways to speed up your site

@portentint

No keep-alive

Sure!may i have

index.html?

ok! can I have styles.css? uh, okthanks! can i have

jquery.js?

can i have image.gif?

Page 157: Lots of ways to speed up your site

@portentint

Maintains connection, so fewer ‘handshakes’

Keep-alive

Page 158: Lots of ways to speed up your site

@portentint

Keep-alive

Sure!can i have index.html, image.gif, jquery.js

and styles.css please?

Page 159: Lots of ways to speed up your site

@portentint

USE WHEN Always

Page 160: Lots of ways to speed up your site

@portentint

php/code acceleration

difficul: impact:

Page 161: Lots of ways to speed up your site

@portentint

Xcache APC

Page 162: Lots of ways to speed up your site

@portentint

USE WHEN It’s available

Page 163: Lots of ways to speed up your site

@portentint

pre-rendering/server caching

difficul: impact:

Page 164: Lots of ways to speed up your site

@portentint

Request page

Store rendered page

Deliver page

Generate page Web/application server

Phantomjs

Cache server

Page 165: Lots of ways to speed up your site

@portentint

USE WHEN It’s doable

Page 166: Lots of ways to speed up your site

@portentint

HERE’S THE THING TEST!!!

whoopsie

Page 167: Lots of ways to speed up your site

@portentint

GOOGLE AMP? FACEBOOK INSTANT PAGES?

Page 168: Lots of ways to speed up your site

@portentint

First, do it right

Page 169: Lots of ways to speed up your site

@portentint

MORE TO DO

Page 170: Lots of ways to speed up your site

@portentint

Sprites/Reduce HTTP calls Responsive image scaling

CSS optimization Javascript optimization

Cookieless delivery

Page 171: Lots of ways to speed up your site

@portentint

REMEMBER THE BOTTLENECKS

Page 172: Lots of ways to speed up your site

@portentint

SERVING

Page 173: Lots of ways to speed up your site

@portentint

TRANSMISSION

Page 174: Lots of ways to speed up your site

@portentint

RENDERING

Page 175: Lots of ways to speed up your site

@portentint

HERE’S THE THING TEST!!!

Page 176: Lots of ways to speed up your site

@portentint

Ian Lurie @portentint www.portent.com

hp://portent.co/speedy-sites hp://portent.co/page-speed-guide