17% 83% iGoogle, primed cache the importance of frontend performance 9%91% iGoogle, empty cache.

Slides:



Advertisements
Similar presentations
High Performance Web Sites 14 rules for faster pages
Advertisements

Web 2.0 Programming 1 © Tongji University, Computer Science and Technology. Web Web Programming Technology 2012.
Optimizing Websites with YSlow Tom Lianza Co-Founder Wishlisting.com Tom Lianza Co-Founder Wishlisting.com.
Building Fast 3rd-Party Webapps O'Reilly Velocity Web Performance and Operations Conference 24 June Lessons.
CS193H: High Performance Web Sites Lecture 7: Add an Expires Header Steve Souders Google
Steve Souders Even Faster Websites Disclaimer: This content does not necessarily reflect.
Steve Souders Even Faster Themes Disclaimer: This content does not necessarily reflect.
17% 83% iGoogle, primed cache the importance of frontend performance 9%91% iGoogle, empty cache.
High Performance Web Sites Essential Knowledge for Frontend Engineers
17% 83% iGoogle, primed cache the importance of frontend performance 9%91% iGoogle, empty cache.
Steve Souders Even Faster Web Sites Disclaimer: This content does not necessarily.
Steve Souders Even Faster Web Sites best practices for faster pages Disclaimer: This.
Steve Souders Even Faster Web Sites Disclaimer: This content does not necessarily reflect.
Steve Souders Even Faster Web Sites Disclaimer: This content does not necessarily.
Steve Souders Even Faster Web Sites (inside ma.tt) best practices for faster pages.
17% 83% iGoogle, primed cache the importance of frontend performance 9%91% iGoogle, empty cache.
CS193H: High Performance Web Sites Lecture 13: Rule 10 – Minify JavaScript Steve Souders Google
Steve Souders Even Faster Web Sites Disclaimer: This content does not necessarily.
CS193H: High Performance Web Sites Lecture 22: Vol 2 – Optimize Images, Use Iframes Sparingly, Flush the Document Early Steve Souders Google
Steve Souders High Performance Widgets Disclaimer: This content does not necessarily.
Steve Souders Life's too short, write fast code part 1 Disclaimer: This content does.
Steve Souders Even Faster Web Sites best practices for faster pages Disclaimer:
CS193H: High Performance Web Sites Lecture 1: Introduction Steve Souders Google
CS193H: High Performance Web Sites Lecture 17: Rule 14 – Make Ajax Cacheable Steve Souders Google
Steve Souders Even Faster Web Sites Disclaimer: This content does not necessarily reflect.
CS193H: High Performance Web Sites Lecture 8: Rule 4 – Gzip Components
CS193H: High Performance Web Sites Lecture 21: Vol 2 – Split Dominant Domains Steve Souders Google
High Performance Web Sites Essential Knowledge for Frontend Engineers
CS193H: High Performance Web Sites Lecture 15: Rule 12 – Remove Duplicate Scripts Steve Souders Google
Exceptional Performance Evolution at Yahoo! Steve Souders Chief Performance Yahoo!
Steve Souders Even Faster Web Sites Disclaimer: This content does not necessarily reflect.
CS193H: High Performance Web Sites Lecture 6: Use a CDN Steve Souders Google
Steve Souders Even Faster Web Sites Disclaimer: This content does not necessarily reflect.
Steve Souders Even Faster Web Sites Disclaimer: This content does not necessarily.
Steve Souders Even Faster Web Sites best practices for faster pages Disclaimer: This content does not necessarily.
Steve Souders Life's too short, write fast code part 1 Disclaimer: This content does.
CS193H: High Performance Web Sites Lecture 20: Vol 2 – Don't Scatter Inline Scripts Steve Souders Google
Steve Souders Even Faster Web Sites best practices for faster pages Disclaimer: This content does not necessarily.
CS193H: High Performance Web Sites Lecture 5: Make Fewer HTTP Requests Steve Souders Google
CS193H: High Performance Web Sites Lecture 12: Rule 8 – Make JavaScript and CSS External Steve Souders Google
CS193H: High Performance Web Sites Lecture 19: Vol 2 – Load Scripts Without Blocking Steve Souders Google
CS193H: High Performance Web Sites Lecture 10: Rule 6 – Put Scripts at the Bottom Steve Souders Google
CS193H: High Performance Web Sites Lecture 2: The Importance of Frontend Performance Steve Souders Google
CS193H: High Performance Web Sites Lecture 11: Rule 7 – Avoid CSS Expressions Rule 9 – Reduce DNS Lookups Steve Souders Google
CS193H: High Performance Web Sites Lecture 18: Vol 2 – Split the Initial Payload Steve Souders Google
Web Performance Meetup 1 Web Performance 101 Jeremy
Web Performance Meetup 1 Web Performance Toolbelt Jeremy
Stevesouders.com/docs/velocity-wpo pptx Disclaimer: This content does not necessarily reflect the opinions of my employer.
Web Site Performance What makes web sites slow? Back end Front end Tools for measuring performance Firebug / YSlow Visual Studio Test Edition W3.org html.
CS193H: High Performance Web Sites Lecture 24: Vol 2 – CSS Descendant Selectors, Forced Compression Steve Souders Google
Copyright © Steven W. Johnson
©2013 AKAMAI | FASTER FORWARD TM It's all about Performance Measured and Perceived Performance on Desktop and Mobile Devices San Mateo Meetup, July 2013.
Disclaimer: This content does not necessarily reflect the opinions of my employer.
High Performance Websites (Based on Steve Souder’s lecture) By Bhoomi Patel.
Disclaimer: This content does not necessarily reflect the opinions of my employer.
&.zip Disclaimer: This content does not necessarily reflect the opinions of my employer.
Stevesouders.com/docs/velocity-efws pptx Disclaimer: This content does not necessarily reflect the opinions of my employer. flickr.com/photos/ddfic/ /
Mark Phillip markphillip.com 200s, 304s, Expires Headers, HTTP Compression, And You.
Disclaimer: This content does not necessarily reflect the opinions of my employer.
Ajax (Asynchronous JavaScript and XML). AJAX  Enable asynchronous communication between a web client and a server.  A client is not blocked when an.
CSE 190: Internet E-Commerce Lecture 5. Exam Material Lectures 1-4 (Presentation Tier) –3-tier architecture –HTML –Style sheets –Javascript –DOM –HTTP.
Stevesouders.com/docs/thinkvitamin pptx Disclaimer: This content does not necessarily reflect the opinions of my employer. flickr.com/photos/ddfic/ /
Putting Performance Best Practices Together to Create the Perfect SPA Chris Love2Dev.com.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
Web Technologies Lecture 7 Synchronous vs. asynchronous.
 AJAX technology  Rich User Experience  Characteristics  Real live examples  JavaScript and AJAX  Web application workflow model – synchronous vs.
Even Faster Web Sites best practices for faster pages
Even Faster Web Sites best practices for faster pages
Even Faster Web Sites cc:
High Performance Mobile
Presentation transcript:

17% 83% iGoogle, primed cache the importance of frontend performance 9%91% iGoogle, empty cache

Empty CachePrimed Cache search.live.com/results67%0% en.wikipedia.org/wiki94%91% April 2008 time spent on the frontend

80-90% of the end-user response time is spent on the frontend. Start there. greater potential for improvement simpler proven to work the performance golden rule

Sept 2007

June 2009

14 R ULES 1.M AKE FEWER HTTP REQUESTS 2.U SE A CDN 3.A DD AN E XPIRES HEADER 4.G ZIP COMPONENTS 5.P UT STYLESHEETS AT THE TOP 6.P UT SCRIPTS AT THE BOTTOM 7.A VOID CSS EXPRESSIONS 8.M AKE JS AND CSS EXTERNAL 9.R EDUCE DNS LOOKUPS 10.M INIFY JS 11.A VOID REDIRECTS 12.R EMOVE DUPLICATE SCRIPTS 13.C ONFIGURE ET AGS 14.M AKE AJAX CACHEABLE

Even Faster Web Sites Splitting the initial payload Loading scripts without blocking Coupling asynchronous scripts Positioning inline scripts Sharding dominant domains Flushing the document early Using iframes sparingly Simplifying CSS Selectors Understanding Ajax performance Doug Crockford Creating responsive web apps Ben Galbraith, Dion Almaer Writing efficient JavaScript Nicholas Zakas Scaling with Comet Dylan Schiemann Going beyond gzipping Tony Gentilcore Optimizing images Stoyan Stefanov, Nicole Sullivan

AOL eBay Facebook MySpace Wikipedia Yahoo! Why focus on JavaScript? YouTube

scripts block blocks parallel downloads and rendering 7 secs: IE 8, FF 3.5(?), Chr 2, Saf 4 9 secs: IE 6-7, FF 3.0, Chr 1, Op 9-10, Saf 3

JavaScript Functions Executed before onload % search.live.com/results17K24% en.wikipedia.org/wiki114K32% % avg 252K avg initial payload and execution

splitting the initial payload split your JavaScript between what's needed to render the page and everything else load "everything else" after the page is rendered separate manually (Page Speed); tools needed to automate this (Doloto) load scripts without blocking – how?

MSN Scripts and other resources downloaded in parallel! How? Secret sauce?! var p= g.getElementsByTagName("HEAD")[0]; var c=g.createElement("script"); c.type="text/javascript"; c.onreadystatechange=n; c.onerror=c.onload=k; c.src=e; p.appendChild(c) MSN.com: parallel scripts

Loading Scripts Without Blocking XHR Eval XHR Injection Script in Iframe Script DOM Element Script Defer document.write Script Tag

XHR Eval script must have same domain as main page must refactor script var xhrObj = getXHRObject(); xhrObj.onreadystatechange = function() { if ( xhrObj.readyState != 4 ) return; eval(xhrObj.responseText); }; xhrObj.open('GET', 'A.js', true); xhrObj.send('');

XHR Injection var xhrObj = getXHRObject(); xhrObj.onreadystatechange = function() { if ( xhrObj.readyState != 4 ) return; var se=document.createElement('script'); document.getElementsByTagName('head') [0].appendChild(se); se.text = xhrObj.responseText; }; xhrObj.open('GET', 'A.js', true); xhrObj.send(''); script must have same domain as main page

Script in Iframe <iframe src='A.html' width=0 height=0 frameborder=0 id=frame1> iframe must have same domain as main page must refactor script: // access iframe from main page window.frames[0].createNewDiv(); // access main page from iframe parent.document.createElement('div');

Script DOM Element var se = document.createElement('script'); se.src = ' document.getElementsByTagName('head') [0].appendChild(se); script and main page domains can differ no need to refactor JavaScript

only supported in IE (just landed in FF 3.1) script and main page domains can differ no need to refactor JavaScript Script Defer

document.write(" "); parallelization only works in IE parallel downloads for scripts, nothing else all document.write s must be in same script block document.write Script Tag

browser busy indicators

status bar progress bar logocursor block render block onload normal Script Src FFIE,FF FFIE,FF XHR Eval no XHR Injection no Script in Iframe IE,FFFFIE,FFFFnoIE,FF Script DOM Element FF noFF Script Defer FF IE,FF document.write Script Tag FFIE,FF FFIE,FF good to show busy indicators when the user needs feedback bad when downloading in the background browser busy indicators

Ensure scripts execute in order: necessary when scripts have dependencies IE: FF: Avoid scripts executing in order: faster – first script back is executed immediately ensure/avoid ordered execution

|| down- loads domains can differ existing scripts browser busy ensures order size (bytes) normal Script Src noyes IE,FF ~50 XHR Eval IE,FFno ~500 XHR Injection IE,FFnoyesno ~500 Script in Iframe IE,FFno IE,FFno~50 Script DOM Element IE,FFyes FF ~200 Script Defer IEyes IE,FFIE~50 document.write Script Tag IE * yes IE,FFIE~100 * Only other document.write scripts are downloaded in parallel (in the same script block). Load Scripts Without Blocking

XHR Eval XHR Injection Script in iframe Script DOM Element Script Defer Script DOM Element Script Defer Script DOM Element Script DOM Element (FF) Script Defer (IE) XHR Eval XHR Injection Script in iframe Script DOM Element (IE) XHR Injection XHR Eval Script DOM Element (IE) Managed XHR Injection Managed XHR Eval Script DOM Element Managed XHR Injection Managed XHR Eval Script DOM Element (FF) Script Defer (IE) Managed XHR Eval Managed XHR Injection Script DOM Element (FF) Script Defer (IE) Managed XHR Eval Managed XHR Injection different domains same domains no order preserve orderno order no busy show busy no busy preserve order and the winner is...

Loading Scripts Without Blocking don't let scripts block other downloads you can still control execution order, busy indicators, and onload event What about inline scripts?

browsers download stylesheets in parallel with other resources that follow......unless the stylesheet is followed by an inline script best to move inline scripts above stylesheets or below other resources use Link, bad: stylesheet followed by inline script

eBay MSN MySpace Wikipedia mispositioned inline scripts

Positioning Inline Scripts remember inline scripts carry a cost avoid long-executing inline scripts don't put inline scripts between stylesheets and other resources

going beyond gzipping Tony Gentilcore, Chapter 9, Even Faster Web Sites Rule 4: Gzip Components from HPWS HTTP/1.1 request: Accept-Encoding: gzip,deflate response: Content-Encoding: gzip Apache 2.x: AddOutputFilterByType DEFLATE text/html text/css application/x- javascript

benefits of gzipping 70% reduction in transfer size not just for HTML!! all text: JavaScript, CSS, XML, JSON not binary: images, PDF, Flash

so what's the issue? 15% of users get uncompressed responses surprize! why? old browsers? no Netscape Navigator 3 – 0.0% Netscape Communicator 4 – 0.1% Opera 3.5 – 0.0% IE <3 – 0.01% clue: most prevalent in the Middle East

who's stripping? proxy, A-V softwareAccept-Encoding header Ad Muncherstripped CA Internet Security Suite Accept-EncodXng: gzip, deflate CEQURUXstripped Citrix Application Firewallstripped ISA 2006stripped McAfee Internet Security 6.0 XXXXXXXXXXXXXXX: Norton Internet Security : Novell iChain 2.3stripped Novell Client Firewallstripped WebWasherstripped ZoneAlarm Pro 5.5 XXXXXXXXXXXXXXX: XXXXXXXXXXXXX proxies and anti-virus software disable compression for easier response filtering

what to do don't assume compression go the extra mile to reduce response size event delegation (-5%)* relative URLs (-3%) minify HTML, JavaScript, and CSS (-4%) use CSS rules over inline styles (-1%) alias long JavaScript symbol names (??) Thanks, Tony! see Tony's chapter in Even Faster Web Sites * Results of applying each technique to the Alexa top ten

JS after CSS (p 77) HTTP/1.0 (p 78) sprite on home page (hpws p 130) Expires header (p 131) FIXED on en.wiki gzip stylesheets – FIXED png optimization – FIXED querystring in static resources main.css?233xz vs. main.css?233yz ??? combine 6 scripts, 9 stylesheets sprite – 8 bg images no Expires on upload.wikimedia.org move 6 scripts lower minify JS – 36K out of 100K (36%) 50% CSS unused (40K out of 80K) flushing! http/1.0! PNGs optimized! put script block above stylesheets load scripts in parallel 81% of JS unused by onload c ombine 6 scripts, 9 stylesheets sprite – 7 bg images no Expires on upload.wikimedia.org move 6 scripts lower minify JS – 36K out of 100K (36%) 50% CSS unused (40K out of 80K) flushing! http/1.0! optimize some images (8%, 48K/624K), put script block above stylesheets load scripts in parallel 81% of JS unused by onload addButton – loads images after onload ?!?! asldjf

JS after CSS (p 77) HTTP/1.0 (p 78) sprite on home page (hpws p 130) Expires header (p 131) FIXED on en.wiki gzip stylesheets – FIXED png optimization – FIXED querystring in static resources main.css?233xz vs. main.css?233yz ??? addButton – loads images after onload ?!?! combine 9 scripts, 9 stylesheets no Expires on upload.wikimedia.org move 9 scripts lower minify JS – 44K out of 126K (35%) 50% CSS unused (40K out of 80K) flushing! http/1.0! PNGs optimized! put script block above stylesheets load scripts in parallel 76% of JS unused by onload asldjf

White Dwarf

White Dwarf add Expires to upload.w.o don't use querystring: ?233yz add Expires to upload.w.o don't use querystring: ?233yz move inline script combine scripts minify (36K, 36%) move lower load async 81% deferrable combine scripts minify (36K, 36%) move lower load async 81% deferrable combine stylesheets remove unused CSS (50%) sprite 8 bg images combine stylesheets remove unused CSS (50%) sprite 8 bg images

add Expires to upload.w.o don't use querystring: ?233yz don't change URL: 233yz v 233zz add Expires to upload.w.o don't use querystring: ?233yz don't change URL: 233yz v 233zz move inline script combine scripts minify (44K, 35%) move lower load async 76% deferrable combine scripts minify (44K, 35%) move lower load async 76% deferrable combine stylesheets remove unused CSS (50%) combine stylesheets remove unused CSS (50%)

focus on the frontend run YSlow ( and Page Speed! ( ) speed matters takeaways

Bing: Yahoo: Google: AOL: Shopzilla: ms -4.3% revenue/user ms -5-9% full-page traffic ms -0.59% searches/user 1 fastest users +50% page views ms +7-12% revenue 4 impact on revenue

hardware – reduced load Shopzilla – 50% fewer servers bandwidth – reduced response size cost savings

if you want better user experience more revenue reduced operating expenses the strategy is clear Even Faster Web Sites

Steve Souders