@media - even faster web sites

50
stevesouders.com/docs/atmedia-20100611.pptx Disclaimer: This content does not necessarily reflect the opinions of my employer. Even Faster Web Sites flickr.com/photos/ddfic/722634166/

Upload: steve-souders

Post on 07-May-2015

15.091 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: @media - Even Faster Web Sites

stevesouders.com/docs/atmedia-20100611.pptx

Disclaimer: This content does not necessarily reflect the opinions of my employer.

Even

Faster

Web Sites

flickr.com/photos/ddfic/722634166/

Page 2: @media - Even Faster Web Sites

flickr.com/photos/bekahstargazing/318930460/

Page 3: @media - Even Faster Web Sites

#1. Speed: “First and foremost, we believe that

speed is more than a feature. Speed is the most

important feature.”

carsonified.com/blog/business/fred-wilsons-10-golden-principles-of-successful-web-apps/

Page 4: @media - Even Faster Web Sites

en.oreilly.com/velocity2009/public/schedule/detail/8523

Page 5: @media - Even Faster Web Sites

en.oreilly.com/velocity2009/public/schedule/detail/8523

Page 6: @media - Even Faster Web Sites

Yahoo!

0.4 sec slower

traffic 5-9%

slideshare.net/stoyan/yslow-20-presentationslideshare.net/stoyan/dont-make-me-wait-or-building-highperformance-web-applications

Page 7: @media - Even Faster Web Sites

blog.mozilla.com/metrics/category/website-optimization/

…shaved 2.2 seconds off the average page load

time and increased download conversions by

15.4%!

Page 8: @media - Even Faster Web Sites

blog.mozilla.com/metrics/category/website-optimization/

…shaved 2.2 seconds off the average page load

time and increased download conversions by

15.4%!

en.oreilly.com/velocity2009/public/schedule/detail/7709

Page 9: @media - Even Faster Web Sites

en.oreilly.com/velocity2008/public/schedule/detail/3632

Page 10: @media - Even Faster Web Sites

Site speed in search rank

Screen shot of blog post

googlewebmastercentral.blogspot.com/2010/04/using-site-speed-in-web-search-ranking.html

…we've decided to take site speed into account in

our search rankings.

Page 11: @media - Even Faster Web Sites
Page 12: @media - Even Faster Web Sites

Bothcombine scripts

combine stylesheets

add an Expires header

gzip responses

put stylesheets at the top

put scripts at the bottom

avoid CSS expressions

make JS and CSS external

reduce DNS lookups

minify JS and CSS

avoid redirects

remove duplicate scripts

make Ajax cacheable

reduce cookie size

use cookie-free domains

don't scale images

YSlowuse CSS sprites

use a CDN

configure ETags

use GET for Ajax requests

reduce # of DOM elements

no 404s

avoid image filters

optimize faviconPage Speeddefer loading JS

remove unused CSS

use efficient CSS selectors

optimize images

optimize order of CSS & JS

shard domains

leverage proxy caching

Page 13: @media - Even Faster Web Sites
Page 14: @media - Even Faster Web Sites
Page 15: @media - Even Faster Web Sites
Page 16: @media - Even Faster Web Sites
Page 17: @media - Even Faster Web Sites

drives traffic

improves UX

increases revenue

reduces costs flickr.com/photos/pedromourapinheiro/3123885534/

Web

Performance

OptimizationWPO

Page 18: @media - Even Faster Web Sites

What makes sites feel slow?

http://www.flickr.com/photos/kevincollins/

234678305/

Page 19: @media - Even Faster Web Sites

[next page being loaded]

(lack of)

Progressive Rendering

http://www.flickr.com/photos/kevincollins/

234678305/

Page 20: @media - Even Faster Web Sites

Search

Page 21: @media - Even Faster Web Sites

Sports

Page 22: @media - Even Faster Web Sites

News

Page 23: @media - Even Faster Web Sites

Shopping

Page 24: @media - Even Faster Web Sites
Page 25: @media - Even Faster Web Sites
Page 26: @media - Even Faster Web Sites
Page 27: @media - Even Faster Web Sites
Page 28: @media - Even Faster Web Sites

Progressive

Enhancementdeliver HTML

defer JS

avoid DOM

decorate later

Page 29: @media - Even Faster Web Sites

Progressive

Enhancement

Progressive Rendering

Page 30: @media - Even Faster Web Sites

<script src="A.js"> blocks parallel downloads and rendering

7 secs: IE 8, FF 3.5, Chr 3, Saf 4

9 secs: IE 6-7, FF 3.0, Chr 1, Op 9-10, Saf 3

Why focus on JavaScript?

Page 31: @media - Even Faster Web Sites

JavaScript

Functions Executed before onload

www.aol.com 324 K 30%

www.ebay.com 234 K 34%

www.facebook.com 553 K 7%

www.google.com/search

21 K ??%

www.bing.com/search 10 K 35%

www.msn.com 152 K 55%

www.myspace.com 248 K 29%

en.wikipedia.org/wiki 99 K 19%

www.yahoo.com 381 K 33%

www.youtube.com 274 K 16% 29% avg229 K avg

initial payload and execution

Page 32: @media - Even Faster Web Sites

split the initial payload

split your JavaScript between what's needed to render

the page and everything else

defer "everything else"

split manually (Page Speed), automatically (Microsoft

Doloto)

load scripts without blocking

http://www.flickr.com/photos/devcentre/108032900/

Page 33: @media - Even Faster Web Sites

Loading Scripts Without Blocking

XHR Eval

XHR Injection

Script in Iframe

Script DOM Element

Script Defer

document.write Script Tag

Page 34: @media - Even Faster Web Sites

XHR Eval

script & page must be same domain

massage script?

var xhrObj = getXHRObject();

xhrObj.onreadystatechange =

function() {

if ( xhrObj.readyState != 4 ) return;

eval(xhrObj.responseText);

};

xhrObj.open('GET', 'A.js', true);

xhrObj.send('');

Page 35: @media - Even Faster Web Sites

Script DOM Elementvar se = document.createElement('script');

se.src = 'http://anydomain.com/A.js';

document.getElementsByTagName('head')

[0].appendChild(se);

script & page domains can differ

no need to massage JavaScript

may not preserve execution order

Page 36: @media - Even Faster Web Sites

GMail Mobile<script type="text/javascript">

/*

var ...

*/

</script>

get script DOM element's text

remove comments

eval() when invoked

inline or iframe

awesome for prefetching JS that might (not) be needed

Page 37: @media - Even Faster Web Sites
Page 38: @media - Even Faster Web Sites

window.setTimeout(function(){ var a=document.createElement("script"); a.src="/extern_js/f/CgJlbhz8US8_w.js"; (document.getElementById("xjsd")|| document.body).appendChild(a);},0);

Google Search

Page 39: @media - Even Faster Web Sites

Bootloader.setResourceMap({"CDYbm": {"name":"js\/32kskxvl4c8w0848.pkg.js", "type":"js", "src":"http:\/\/...\/1fakc64i.js"}, ...});

var c=a ? document.body : document.getElementsByTagName('head')[0];

var d=document.createElement('script');d.type='text/javascript';d.src=f;c.appendChild(d);

Facebook

Page 40: @media - Even Faster Web Sites

YUI.presentation.lazyScriptList = ["http://l.yimg.com/a/combo?arc/yui/substitute_0.1.9.js&arc/yui/oop_0.1.10.js&[...58 more!...]"];

d = w.document; h = d.getElementsByTagName("head")[0];n = d.createElement("script"),n.src = url;h.appendChild(n);

Yahoo! FP

Page 41: @media - Even Faster Web Sites

<script src="http://bits.wikimedia.org/skins-1.5/common/wikibits.js?281c" type="text/javascript"></script><script src="http://bits.wikimedia.org/skins-1.5/common/jquery.min.js?281c" type="text/javascript"></script><script src="http://bits.wikimedia.org/skins-1.5/common/ajax.js?281c" type="text/javascript"></script><script src="http://bits.wikimedia.org/skins-1.5/common/mwsuggest.js?281c" type="text/javascript"></script><script src="http://bits.wikimedia.org/w/extensions/UsabilityInitiative/js/plugins.combined.min.js?281c" type="text/javascript"></script><script src="http://bits.wikimedia.org/w/extensions/UsabilityInitiative/Vector/Vector.combined.min.js?281c" type="text/javascript"></script><script src="http://upload.wikimedia.org/centralnotice/wikipedia/en/centralnotice.js?281c" type="text/javascript"></script><script src="/w/index.php?title=-&amp;action=raw&amp;gen=js&amp;useskin=vector&amp;281c" type="text/javascript"></script></head>

Wikipedia

Page 42: @media - Even Faster Web Sites

<script src="/js/jquery-1.4.2.js"></script></body></html>

subsequent page:<script src="/js/jquery-1.4.2.js"></script><script src="/js/toChecklist.js"></script><script src="/js/tocs.js"></script></body></html>

Craigslist

Page 43: @media - Even Faster Web Sites

<script src="http://include.ebaystatic.com/v4js/en_US/e673/SYS-RA_vjo_e67311309442_1_en_US.js"></script><script src="http://include.ebaystatic.com/v4js/en_US/e673/GH-RA_ReskinEbay_e67311309442_1_en_US.js"></script><script src="http://include.ebaystatic.com/v4js/en_US/e673/SYS-RA_vjo_e67311252543_opta_en_US.js"><script src="http://include.ebaystatic.com/v4js/en_US/e673/CCHP_HomepageV4_SLDR_e67311252543_6_en_US.js"></script>

eBay

Page 44: @media - Even Faster Web Sites

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js" type="text/javascript"></script><script src="http://a3.twimg.com/a/1276018586/javascripts/twitter.js?1276019402" type="text/javascript"></script><script src="http://a1.twimg.com/a/1276018586/javascripts/lib/jquery.tipsy.min.js?1276019402" type="text/javascript"></script>

<script src='http://maps.google.com/maps/api/js?sensor=false' type="text/javascript"></script><script src="http://a1.twimg.com/a/1276018586/javascripts/lib/gears_init.js?1276019402" type="text/javascript"></script><script src="http://a3.twimg.com/a/1276018586/javascripts/geov1.js?1276019402" type="text/javascript"></script><script src="http://a1.twimg.com/a/1276018586/javascripts/api.js?1276019402" type="text/javascript"></script><script src="http://a2.twimg.com/a/1276018586/javascripts/lib/mustache.js?1276019402" type="text/javascript"></script><script src="http://a3.twimg.com/a/1276018586/javascripts/dismissable.js?1276019402" type="text/javascript"></script><script src="http://a1.twimg.com/a/1276018586/javascripts/api.js?1276019402" type="text/javascript"></script><script src="http://a0.twimg.com/a/1276018586/javascripts/controls.js?1276019402" type="text/javascript"></script><script src="http://a1.twimg.com/a/1276018586/javascripts/hover_cards.js?1276019402" type="text/javascript"></script></body></html>

Twitter

Page 45: @media - Even Faster Web Sites

var a=_d.createElement("script");a.type="text/javascript";a.src=b;_d.getElementsByTagName("head")[0].appendChild(a);

Bing

onload

Page 46: @media - Even Faster Web Sites
Page 47: @media - Even Faster Web Sites

http://www.flickr.com/photos/waltzaround/4041024134/

Ray Morgan

Zappos.com

Makinde Adeagbo

Facebook

Jenn Lukas

Happy Cog

Page 48: @media - Even Faster Web Sites
Page 49: @media - Even Faster Web Sites

speed matters

focus on the frontend

run Page Speed and YSlow

progressive enhancement progressive rendering

takeaways

http://www.flickr.com/photos/34771728@N00/361526991/

Page 50: @media - Even Faster Web Sites

Steve Souders

@souders, [email protected]

stevesouders.com/docs/atmedia-20100611.pptx

flickr.com/photos/nj_dodge/187190601/