Slide 1

Slide 1 text

Measuring your websites performance Patrick Hamann Front-end London - April 2013 Why performance matters

Slide 2

Slide 2 text

Who am I? • @patrickhamann • Client-side developer • Performance geek

Slide 3

Slide 3 text

Who I work for

Slide 4

Slide 4 text

What am I going to cover?

Slide 5

Slide 5 text

What am I going to cover? • Why performance matters

Slide 6

Slide 6 text

What am I going to cover? • Why performance matters • How to measure your websites performance bottlenecks

Slide 7

Slide 7 text

What am I going to cover? • Why performance matters • How to measure your websites performance bottlenecks • Myths, tips and best practices

Slide 8

Slide 8 text

Ideal load time?

Slide 9

Slide 9 text

< 3 secs

Slide 10

Slide 10 text

Reality:

Slide 11

Slide 11 text

7.25 secs

Slide 12

Slide 12 text

Page weight is increasing YoY Source: HTTPArchive

Slide 13

Slide 13 text

1.4 Mb

Slide 14

Slide 14 text

User load time expectations Source: Web Performance Today

Slide 15

Slide 15 text

71% of users want your mobile site to load as fast as the desktop equivalent. Source: Gomez

Slide 16

Slide 16 text

"We made the new platform 60% faster and this resulted in a 14% increase in donation conversions." Kyle Rush - Obama Campaign

Slide 17

Slide 17 text

Measuring performance Tools

Slide 18

Slide 18 text

The critical path Network Parse Paint

Slide 19

Slide 19 text

Waterfall analysis

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

Size

Slide 23

Slide 23 text

Size Latency

Slide 24

Slide 24 text

Size Latency Download

Slide 25

Slide 25 text

Size Latency Download DOMContentReady

Slide 26

Slide 26 text

Size Latency Download DOMContentReady Load

Slide 27

Slide 27 text

WebPageTest.org

Slide 28

Slide 28 text

WebPageTest.org

Slide 29

Slide 29 text

WebPageTest.org

Slide 30

Slide 30 text

WebPageTest.org

Slide 31

Slide 31 text

WebPageTest.org

Slide 32

Slide 32 text

WebPageTest.org

Slide 33

Slide 33 text

WebPageTest : Comparison

Slide 34

Slide 34 text

WebPageTest : Video

Slide 35

Slide 35 text

PROBLEMS

Slide 36

Slide 36 text

Common performance bottlenecks • Latency • Payload • Caching • Paint

Slide 37

Slide 37 text

Latency • Time to first byte (TTFB) • Incurred on every request • Much worse on mobile • CDN’s • The closer to the user, the lower the latency • Edge side compression • HTML ?!

Slide 38

Slide 38 text

Reduce payload: 101 • Compression • GZip (mod_deflate mod_pagespeed) • Concatenate CSS/JS • Defer to load event (lazy-load) • Conditional loading • Cache

Slide 39

Slide 39 text

Reduce payload: CSS • Only resource that should block the parser! • Load only bare minimum for page chrome • Conditionally load the rest • Browsers download CSS they don't need : e.g. print, tv, device-ratio... • Serve of same host - no DNS lookup • Inline ?*&%!

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

WTF!

Slide 42

Slide 42 text

Reduce payload: Images • Compression: • Photoshop 60% > ImageOptim 25/70% • Progressive JPEGs • WebP • Base64 icons or icon fonts • Clean SVGs • No images at all?

Slide 43

Slide 43 text

Progressive JPEGs Source: Performance calendar

Slide 44

Slide 44 text

WebP - Content negotiation WebP lossless images are 26% smaller in size compared to PNGs. WebP lossy images are 25-34% smaller in size compared to JPEG Source: NetDNA blog

Slide 45

Slide 45 text

Caching • Far-future cache headers • Invalidation • AppCache is broken :( • Mobile is harder • Smaller shared cache • Stuff critical assets in localStorage

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

WTF!

Slide 48

Slide 48 text

Render • Don't use setTimeout • Use request animation frame instead. • CSS Animations get over these issues. • Avoid recalculation • Bisecting slow CSS styles & elements

Slide 49

Slide 49 text

Render: Timeline Source: Addy Osmani

Slide 50

Slide 50 text

Continuous paint mode Source: HTML5 Rocks

Slide 51

Slide 51 text

R.U.M

Slide 52

Slide 52 text

Navigation timing API Source: W3C

Slide 53

Slide 53 text

Navigation timing API Source: W3C

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

Google Analytics: Site Speed

Slide 57

Slide 57 text

HAR

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

Automation: PhantomJS & YSlow Source: Ilya Grigorik

Slide 60

Slide 60 text

Automation: HAR Storage Source: https://code.google.com/p/harstorage/

Slide 61

Slide 61 text

Automation: CI Integration Build Test Deploy Users Monitor

Slide 62

Slide 62 text

Automation: CI Integration Build Test Deploy Users Monitor YSlow

Slide 63

Slide 63 text

The Future

Slide 64

Slide 64 text

The Future • SPDY/HTTP 2.0

Slide 65

Slide 65 text

The Future • SPDY/HTTP 2.0 • Responsive images

Slide 66

Slide 66 text

The Future • SPDY/HTTP 2.0 • Responsive images •

Slide 67

Slide 67 text

The Future • SPDY/HTTP 2.0 • Responsive images • • Application controller

Slide 68

Slide 68 text

The Future • SPDY/HTTP 2.0 • Responsive images • • Application controller • WebP

Slide 69

Slide 69 text

The Future • SPDY/HTTP 2.0 • Responsive images • • Application controller • WebP • Client-hints

Slide 70

Slide 70 text

The Future • SPDY/HTTP 2.0 • Responsive images • • Application controller • WebP • Client-hints • RESS?

Slide 71

Slide 71 text

It sounds easy... • It’s not • Requires a lot of dev time • Maintenance and upkeep • How do you track regression?

Slide 72

Slide 72 text

Performance budget • Optimize an existing feature or asset • Remove an existing feature or asset • Don’t add the new feature or asset

Slide 73

Slide 73 text

PERFORMANCE FIRST

Slide 74

Slide 74 text

Thank you! @patrickhamann Front-end London - April 2013 We’re hiring!