Web performance & user experience


http://xiw.cx/1pMdDwB

WEB ASSETS

HTTP requests

Browsers only allow a certain number of concurrent requests

Browser* Max
Chrome 6
Internet Explorer 8
Firefox 6
Opera 6
Safari 6

* most recent version, bit.ly/1n8fvOt

Concatenation


scripts and stylesheets should be concatenated

styleA.css
body {
  color: red;
}
styleB.css
p {
  color: blue;
}

style-concatenated.css
body {
  color: red;
}

p {
  color: blue;
}

Minification


scripts and stylesheets should be minified

style-concatenated.css
body {
  color: red;
}

p {
  color: blue;
}

style-minified.css
body{color:red;}p{color:blue;}

Optimization


images should be optimized

some recent examples:


1.7MB   ->   ~150KB

47KB   ->   90 byte

<picture> Element

full size images should not be scaled down for smaller screens

<picture>
	<source
		srcset="opera-1x.webp 1x,
				opera-2x.webp 2x,
				opera-3x.webp 3x"
		type="image/webp">
	<img
		src="opera-1x.jpg" alt="The Oslo Opera House"
		srcset="opera-2x.jpg 2x,
				opera-3x.jpg 3x">
</picture>

find out what you could be saving: http://sizersoze.org/

find out how it works: http://dev.opera.com/articles/responsive-images/,
http://ericportis.com/posts/2014/srcset-sizes/

use the polyfill: https://github.com/scottjehl/picturefill

Use videos from the platform


They will load optimizied.



Examples in the boilerplate:

http://www.preview.nationalgeographic.com/specialprojects/boilerplate/

https://github.com/natgeo/special-projects/blob/boilerplate-template/app/index.html#L20-L22

ScriptS & ASYNC


Load scripts right before the close of the <body> element instead of in the <head>

<script async="" src="http://third-party.com/resource.js"></script>

If you have to load third party scripts in the <head>, use the async attribute



http://css-tricks.com/thinking-async/
http://css-tricks.com/async-attribute-scripts-bottom/

POSTPONE


Won't load an image until it's in or near to the visible window.

<img data-src="http://i.imgur.com/kDtVsrE.gif" postpone>

Polyfill for draft specification.

TOOLS


Speed Tests:

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

Network Throttlers:

nshipster.com/network-link-conditioner
www.charlesproxy.com

full list:

confluence.nationalgeographic.com/display/DS/Tools

WHY?

our "mobile" traffic is increasing rapidly

JULY 2013

JULY 2014

Small delays have a big impact


Normal Page Load


500ms Delay Page Load

SMALL DELAYS HAVE A BIG IMPACT


webperformancetoday.com/2014/04/03/slow-pages-hurt-entire-user-experience-slides/
Made with Slides.com