Speed is Essential for a Great Web Experience (Canvas Conf Version)
Speed is Essential for a
Great Web Experience
@andydavies
#CanvasConf
Sep 2012
http://www.flickr.com/photos/barkaway/342359810
But sometimes other concerns take priority...
http://www.flickr.com/photos/randomidea/247994072
“Are we there yet?”
http://www.flickr.com/photos/sharynmorrow/643126727
Our perception of response time
Instant
Seamless Yawn!
100ms 1s 10s
3s - Recommended 7s - Fortune 500
Load Time Average (2010)
Response Time in Man-computer Conversational Transactions
Robert B. Miller, 1968
“50% more concentration when using
badly performing web sites”
Foviance
http://www.flickr.com/photos/yourdon/3366991042
Effect of delay on abandonment rate...
Abandonment rate over 200+ sites / 177+ million page views over 2 weeks - http://www.measureworks.nl / Gomez
80% plus of page load time is on front-end
Backend
news.bbc.co.uk
Frontend
ebay.co.uk
debenhams.co.uk
direct.gov.uk
amazon.co.uk
mumsnet.com
guardian.co.uk
0 1.25 2.5 3.75 5
Measured on residential ADSL line using Chrome 19
Bandwidth (often) isn’t the bottleneck
2.0
1.5
1.0
0.5
0s 5s 10s
news.bbc.co.uk tested via webpagetest.org throttled at 1.5Mbps
(bursts over 1.5Mbps are artefact of testing)
Minimum round trips to download a file
(TCP Segments)
285kB
214kB
143kB
71kB
Size
1 2 3 4 5 6 7 8 9 10 11
Round Trips TCP and the Lower Bound of Web Performance
John Rauser
Get the <head> straight
<!doctype html>
<html>
<head>
CSS before JS
<meta charset="utf-8"> Ideally one file*
<title>This is my title<title>
<link rel="stylesheet" href="styles.css" type="text/css" />
<script src="script.js"></script>
.
. Only JS needed
. during page load
</head>
* Bryan and Stephanie Rieger’s major and minor breakpoint approach requires multiple CSS files
Load remaining Javascript late as possible
.
.
.
<script src="restofscript.js"></script>
</body>
</html>
One file or many?
(Depends on size)
Could you defer some JS until after onload?
Squash text based content - gzip / minify
http://www.flickr.com/photos/evdg/298415813
Images are 64% of an ‘average’ web page
http://www.flickr.com/photos/zaprittsky/4520788183/
Cache resources that don’t change ‘often’ forever
(use versions to replace)
http://www.flickr.com/photos/sterlingely/64228609
Redirects - necessary but waste time…
Why 2 redirects?
Expensive over mobile networks due to latency
The Perils of Third Party Javascript...
“Virgin Media Broadband ISP Users
Affected by Website Routing Woes”
ISP Review, May 26, 2012
cg-global.maxymiser.com unreachable
Impact on The Telegraph…
Same issue affected many other sites http://bit.ly/Ncy7Rd
Load Third Party scripts asynchronously
<script type="text/javascript">
function() {
var js = document.createElement('script');
js.async = true;
js.src = 'myscript.js';
var e = document.getElementsByTagName('script')[0];
e.parentNode.insertBefore(js, first);
})();
</script>
async attribute may be option but not supported by IE & Opera
Argh... My brain hurts!
http://www.flickr.com/photos/corneveaux/3248566797
Don’t have to do it all by hand
http://www.flickr.com/photos/simeon_barkas/2557059247