This talk is not about
How to build a rocket-ship
with Javascript
Slide 4
Slide 4 text
This talk is about
Techniques to make our
websites faster
Slide 5
Slide 5 text
THE PROBLEM
Slide 6
Slide 6 text
“75% of mobile users
will leave the site if it
takes more than 5
seconds to load.
http://www.digitalmall.us/1150/smartphone-users-frustrated-with-mobile-web-experience/
Slide 7
Slide 7 text
No content
Slide 8
Slide 8 text
“Today the average
website is 1.7MB
httparchive.org/interesting.php
Slide 9
Slide 9 text
http://httparchive.org/interesting.php?a=All&l=Oct%201%202013&s=Top1000
AVG. SITE
0
1
2
<1mb
2011
1.5mb
2013
2mb
2015
AVG. SITE
0
1
2
AVG. SITE
0
1
2
Slide 10
Slide 10 text
No content
Slide 11
Slide 11 text
No content
Slide 12
Slide 12 text
“87% of mobile users
expect sites to load
at least as fast, or
faster than on their
desktop.
http://www.strangeloopnetworks.com/web-performance-infographics/
Slide 13
Slide 13 text
No content
Slide 14
Slide 14 text
No content
Slide 15
Slide 15 text
No content
Slide 16
Slide 16 text
LET’S START WITH A
PAGE BUDGET
Slide 17
Slide 17 text
No content
Slide 18
Slide 18 text
Example:
Less than 3 seconds
to see something.
Slide 19
Slide 19 text
Example:
Not bigger than 1MB.
Slide 20
Slide 20 text
Example:
No more than 20 requests.
Slide 21
Slide 21 text
Now try to stick to it.
(good luck!)
Slide 22
Slide 22 text
USING ONLINE TOOLS SUCH AS
WEBPAGETEST.ORG
Slide 23
Slide 23 text
No content
Slide 24
Slide 24 text
No content
Slide 25
Slide 25 text
Coffee image
Slide 26
Slide 26 text
No content
Slide 27
Slide 27 text
– Paul Lewis
“The Speed Index is the
average time at which
visible parts of the page
are displayed.
http://aerotwist.com/blog/my-performance-audit-workflow/
Slide 28
Slide 28 text
– Paul Lewis
“Paul Irish has, in the
past, recommended a goal
of less than 1,000.
http://aerotwist.com/blog/my-performance-audit-workflow/
Slide 29
Slide 29 text
Filmstrip
Slide 30
Slide 30 text
OLD-SCHOOL IS STILL COOL
PROGRESSIVE ENHANCEMENT
Slide 31
Slide 31 text
No content
Slide 32
Slide 32 text
– Jake Archibald
“All your users are non-JS
while they're downloading
your JS.
https://twitter.com/jaffathecake/status/207096228339658752
Slide 33
Slide 33 text
Twitter.com dropped initial
page load to 1/5th
by moving rendering to server.
https://blog.twitter.com/2012/improving-performance-twittercom
Slide 34
Slide 34 text
Airbnb experimented serving
real HTML instead of JS and
it felt 5x quicker.
http://nerds.airbnb.com/weve-launched-our-first-nodejs-app-to-product/
Available images and their width
Breakpoints in CSS and image width relative to the viewport
Slide 63
Slide 63 text
http://responsiveimages.org
Slide 64
Slide 64 text
No content
Slide 65
Slide 65 text
https://github.com/
scottjehl/picturefill
Version 2.0
Slide 66
Slide 66 text
front-end & back-end
Javascript
Slide 67
Slide 67 text
Slide 68
Slide 68 text
var imageWidth = image.offsetWidth * window.devicePixelRatio;
!
var src = “http://hej.se/image.jpg?w=“ + imageWidth;
!
image.setAttribute("src", src);
Slide 69
Slide 69 text
Check browser for size and capabilities
Slide 70
Slide 70 text
Check browser for size and capabilities
Request CDN
Slide 71
Slide 71 text
Do we have this image?
Check browser for size and capabilities
Request CDN
Slide 72
Slide 72 text
Return the image
Do we have this image?
Check browser for size and capabilities
Request CDN
Slide 73
Slide 73 text
Prepare the image
Return the image
Do we have this image?
Check browser for size and capabilities
Request CDN
Slide 74
Slide 74 text
Prepare the image
Return the image
Return the image
Do we have this image?
Check browser for size and capabilities
Request CDN
Slide 75
Slide 75 text
No content
Slide 76
Slide 76 text
THE AWESOMENESS OF
SCALE VECTOR GRAPHICS
Slide 77
Slide 77 text
No content
Slide 78
Slide 78 text
SVG
4KB
uncompressed
PNG
10KB
uncompressed
Slide 79
Slide 79 text
And it’s only
markup text
Slide 80
Slide 80 text
Summary
!
!
!
!
!
Slide 81
Slide 81 text
Summary
Be aware. Set a "budget".
!
!
!
Slide 82
Slide 82 text
Summary
Be aware. Set a "budget".
Progressive Enhancement is still cool.
!
!
!
!
Slide 83
Slide 83 text
Summary
Be aware. Set a "budget".
Progressive Enhancement is still cool.
Prioritise loading of content with JS.
!
!
!
!
Slide 84
Slide 84 text
Summary
Be aware. Set a "budget".
Progressive Enhancement is still cool.
Prioritise loading of content with JS.
Images are the biggest hit.
!
!
!
Slide 85
Slide 85 text
Summary
Be aware. Set a "budget".
Progressive Enhancement is still cool
Prioritise loading of content with JS.
Images are the biggest hit.
SVGs are awesome.
!
!
Slide 86
Slide 86 text
Summary
Be aware. Set a "budget".
Progressive Enhancement is still cool
Prioritise loading of content with JS.
Images are the biggest hit.
SVGs are awesome.
!
!
Slide 87
Slide 87 text
Think and prioritise
performance
from day one.
Slide 88
Slide 88 text
“Measure. Treat performance
as a core part of your site’s
quality and don’t ship without
understanding and accepting
it’s performance.
http://www.guypo.com/mobile/performance-implications-of-responsive-design-book-contribution/