Slide 1

Slide 1 text

i! GoMakeThings.com 5 @ChrisFerdinandi #! WICKED FAST WORDPRESS

Slide 2

Slide 2 text

WHY DOES SPEED MATTER?

Slide 3

Slide 3 text

20% decrease in search traffic from just a 500ms delay Source: www.slideshare.net/stubbornella/designing-fast-websites-presentation

Slide 4

Slide 4 text

1% loss in sales from just a 100ms delay Source: www.slideshare.net/stubbornella/designing-fast-websites-presentation

Slide 5

Slide 5 text

$6.1M based on 2012 sales

Slide 6

Slide 6 text

600kb average webpage size in 2010 Source: www.webperformancetoday.com/2013/06/05/web-page-growth-2010-2013/

Slide 7

Slide 7 text

1.2mb average webpage size in 2013 Source: www.webperformancetoday.com/2013/06/05/web-page-growth-2010-2013/

Slide 8

Slide 8 text

2x in just three years Source: www.webperformancetoday.com/2013/06/05/web-page-growth-2010-2013/

Slide 9

Slide 9 text

COMPUTERS GET FASTER EVERY YEAR. Everybody

Slide 10

Slide 10 text

Source: www.lukew.com

Slide 11

Slide 11 text

MOBILE IS THE WEB $!

Slide 12

Slide 12 text

Source: www.google.com/think/research-studies/creating-moments-that-matter.html 77% of mobile searches happen at work or at home ^! =!

Slide 13

Slide 13 text

Source: www.flickr.com/photos/cseeman/4020336221/

Slide 14

Slide 14 text

55% AMERICANS WHO HAVE ACCESSED THE WEB via a mobile device in 2012 Source: blogs.hbr.org/cs/2013/05/the_rise_of_the_mobile-only_us.html

Slide 15

Slide 15 text

31% AMERICANS WHO HAVE PRIMARILY ACCESSED THE WEB via a mobile device in 2012 Source: blogs.hbr.org/cs/2013/05/the_rise_of_the_mobile-only_us.html

Slide 16

Slide 16 text

74% of mobile users will leave your site if it takes more than 5 seconds to load Source: bradfrostweb.com/blog/post/performance-as-design/

Slide 17

Slide 17 text

4G LTE IS AS FAST AS BROADBAND WIFI. Everybody

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

Source: www.flickr.com/photos/elviskennedy/8131276426/

Slide 20

Slide 20 text

Source: www.flickr.com/photos/jonathankosread/8026724727/

Slide 21

Slide 21 text

Source: www.flickr.com/photos/ericparker/2102020762/

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

45% traffic from mobile devices Source: Google Analytics

Slide 27

Slide 27 text

0 5,000 10,000 15,000 20,000 25,000 May 2011 May 2012 January 2013 August 2013 ~9% ~23% ~36% ~45%

Slide 28

Slide 28 text

~70% 1

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

THE PERFECT STORM Bigger sites Weaker devices Higher expectations

Slide 31

Slide 31 text

WHAT CAN YOU DO ABOUT IT?

Slide 32

Slide 32 text

) READS HTML * RENDERS CONTENT + DOWNLOADS FILES (2 at a time) CSS stops rendering JS stops downloads

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

) READS HTML * RENDERS CONTENT + DOWNLOADS FILES (2 at a time) CSS stops rendering JS stops downloads

Slide 35

Slide 35 text

) READS HTML * RENDERS CONTENT + DOWNLOADS FILES (2 at a time) CSS stops rendering JS stops downloads

Slide 36

Slide 36 text

)! HTML ORDER MATTERS

Slide 37

Slide 37 text

CSS AT THE TOP to avoid repaints JS AT THE BOTTOM* to maximize downloads * Exception: Modernizr (and similar scripts)

Slide 38

Slide 38 text

WP_ENQUEUE_STYLE in the header by default

Slide 39

Slide 39 text

WP_ENQUEUE_SCRIPT also in the header by default wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ); true

Slide 40

Slide 40 text

) READS HTML * RENDERS CONTENT + DOWNLOADS FILES (2 at a time) CSS stops rendering JS stops downloads

Slide 41

Slide 41 text

+

Slide 42

Slide 42 text

# FAST 300kb @ SLOW 100kb 100kb 100kb

Slide 43

Slide 43 text

DNS LOOKUPS HTTP HEADERS REDIRECTS 404s Lots of places for things to go wrong ~!

Slide 44

Slide 44 text

COMBINE LIKE FILES -! (concatenation)

Slide 45

Slide 45 text

@ SLOW dropdowns.js fitvids.js modals.js # FAST scripts.js

Slide 46

Slide 46 text

Browsers download all files regardless of screen size @ SLOW header.php

Slide 47

Slide 47 text

# FAST .base-styles { … } @media (min-width: 20em) { … } @media (min-width: 40em) { … } @media (min-width: 60em) { … } header.php style.css

Slide 48

Slide 48 text

file weight

Slide 49

Slide 49 text

REMOVE WHITESPACE s! (minification)

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

~40% reduction in file size

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

STYLE.CSS (human-readable) STYLE.MIN.CSS (minified)

Slide 57

Slide 57 text

REPLACE THIS get_bloginfo('stylesheet_url'); WITH THIS get_bloginfo('stylesheet_directory') . '/style.min.css';

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

No content

Slide 60

Slide 60 text

SCRIPTS.JS (human-readable) SCRIPTS.MIN.JS (minified)

Slide 61

Slide 61 text

PLUGINS MAKE THIS HARD. They also make it easy.

Slide 62

Slide 62 text

MINQUEUE http://wordpress.org/plugins/minqueue/

Slide 63

Slide 63 text

~65% smaller GOOGLE-HOSTED JQUERY //ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

GOOGLE-HOSTED JQUERY http://cferdinandi.github.io/google-hosted-jquery/

Slide 66

Slide 66 text

No content

Slide 67

Slide 67 text

MINIFY YOUR HTML http://cferdinandi.github.io/html-minify/

Slide 68

Slide 68 text

No content

Slide 69

Slide 69 text

No content

Slide 70

Slide 70 text

USE IMAGES WISELY r!

Slide 71

Slide 71 text

ICON FONTS Lightweight A single file Styleable with CSS Scalable Compatible back to IE 5 Considerations 1 color per icon* Windows Phone 7 support sucks

Slide 72

Slide 72 text

@font-face { … } .icon-twitter:before { font-family: icon-font; content: "\e001"; color: #0088cc; font-size: 4em; } 5!

Slide 73

Slide 73 text

Source: icomoon.io

Slide 74

Slide 74 text

Source: icomoon.io

Slide 75

Slide 75 text

HOW TO USE ICON FONTS http://gomakethings.com/icon-fonts/

Slide 76

Slide 76 text

IMAGE SPRITES (background-image instead of @font-face) 5! 0! 2! 3! 4! 1! 5! 0! 2! 3! 4! 1!

Slide 77

Slide 77 text

# FAST 300kb @ SLOW 100kb 100kb 100kb

Slide 78

Slide 78 text

IMAGE SPRITE GENERATOR http://spritegen.website-performance.org/

Slide 79

Slide 79 text

SMARTER IMAGE FORMATS PNGs Logos Clean, simple images JPGs Photos Noisy images

Slide 80

Slide 80 text

DIFFERENT JPG FORMATS Baseline Progressive

Slide 81

Slide 81 text

BROWSER FOREGROUND BACKGROUND Chrome Firefox IE 8 IE 9 Safari Opera BROWSER “SUPPORT” Source: http://calendar.perfplanet.com/2012/progressive-jpegs-a-new-best-practice/

Slide 82

Slide 82 text

COMPRESS JPGs 676kb 92kb

Slide 83

Slide 83 text

87% reduction in file size

Slide 84

Slide 84 text

70 High-quality JPG compression 90 WordPress default

Slide 85

Slide 85 text

add_filter('jpeg_quality', function($arg){return 70;}); Source: www.wpbeginner.com/wp-tutorials/how-to-increase-or-decrease-wordpress-jpeg-image-compression/ not progressive and sometimes fuzzy

Slide 86

Slide 86 text

No content

Slide 87

Slide 87 text

COMPRESS & SHARPEN IMAGES https://github.com/cferdinandi/image-compress-and-sharpen

Slide 88

Slide 88 text

REGENERATE THUMBNAILS http://wordpress.org/plugins/regenerate-thumbnails/

Slide 89

Slide 89 text

Source: imageoptim.com/ SMUSH IMAGES

Slide 90

Slide 90 text

USE ADAPTIVE IMAGES q!

Slide 91

Slide 91 text

http://adaptive-images.com

Slide 92

Slide 92 text

http://jetpack.me/support/photon/

Slide 93

Slide 93 text

COMPRESS YOUR SITE a! (gzipping)

Slide 94

Slide 94 text

~70% reduction in website size Source: developer.yahoo.com/performance/rules.html

Slide 95

Slide 95 text

APACHE .HTACCESS FILE https://github.com/cferdinandi/htaccess

Slide 96

Slide 96 text

# BEGIN WordPress RewriteEngine On RewriteBase /your-site/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /your-site/index.php [L] # END WordPress

Slide 97

Slide 97 text

GZIPWTF http://gzipwtf.com/

Slide 98

Slide 98 text

SET EXPIRE HEADERS c!

Slide 99

Slide 99 text

# Your document html ExpiresByType text/html "access plus 0 seconds" # Media: images, video, audio ExpiresByType image/gif "access plus 1 month" ExpiresByType image/jpeg "access plus 1 month" ExpiresByType image/png "access plus 1 month" ExpiresByType video/mp4 "access plus 1 month" ExpiresByType video/ogg "access plus 1 month"

Slide 100

Slide 100 text

APACHE .HTACCESS FILE https://github.com/cferdinandi/htaccess

Slide 101

Slide 101 text

STYLE.MIN.10262013.CSS

Slide 102

Slide 102 text

MINQUEUE does this automatically

Slide 103

Slide 103 text

! & + & + & = ) ) READS HTML * RENDERS CONTENT + DOWNLOADS FILES (2 at a time) CSS stops rendering JS stops downloads

Slide 104

Slide 104 text

PRE-BUILD YOUR SITE t!

Slide 105

Slide 105 text

! & + & + & = ) ) READS HTML * RENDERS CONTENT + DOWNLOADS FILES (2 at a time) CSS stops rendering JS stops downloads

Slide 106

Slide 106 text

Source: wordpress.org/plugins/quick-cache/

Slide 107

Slide 107 text

COMMENT GARBAGE COLLECTOR http://wordpress.org/plugins/quick-cache-comment-garbagecollector/

Slide 108

Slide 108 text

WEBSITE SPEED TEST http://tools.pingdom.com/fpt/

Slide 109

Slide 109 text

1.  HTML order matters 2.  Combine like files 3.  Remove whitespace 4.  Use icon fonts (or sprites) 5.  Pick the right image format 6.  Compress & smush images 7.  Use adaptive images 8.  Compress your site 9.  Set Expires headers 10.  Prebuild your site #! WICKED FAST WORDPRESS

Slide 110

Slide 110 text

GoMakeThings.com @ChrisFerdinandi [email protected] i! CHRIS FERDINANDI Kraken