<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ajaxian &#187; Performance</title>
	<atom:link href="http://ajaxian.com/by/topic/performance/feed" rel="self" type="application/rss+xml" />
	<link>http://ajaxian.com</link>
	<description>Cleaning up the web with Ajax</description>
	<lastBuildDate>Tue, 22 May 2012 21:45:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
    	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Best Practices for test revisited</title>
		<link>http://ajaxian.com/archives/best-practices-for-test-revisited</link>
		<comments>http://ajaxian.com/archives/best-practices-for-test-revisited#comments</comments>
		<pubDate>Fri, 08 Apr 2011 17:08:30 +0000</pubDate>
		<dc:creator>jvaughan</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=10538</guid>
		<description><![CDATA[With Google and their apps like Search, Docs or GMail only a very small time is actually spent in the initial page load, writes Andreas Grabner in a recent blog post. Of course, much time is spent in JavaScript, XHR Calls and DOM Manipulations triggered by user actions. Grabner writes: It is very important to <a href="http://ajaxian.com/archives/best-practices-for-test-revisited">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p>With Google and their apps like Search, Docs or GMail only a very small time is actually spent in the initial page load, writes <a href="http://blog.dynatrace.com/2011/03/22/testing-and-optimizing-single-page-web-2-0ajax-applications-why-best-practices-alone-dont-work-any-more/">Andreas Grabner in a recent blog post</a>. Of course, much time is spent in JavaScript, XHR Calls and DOM Manipulations triggered by user actions. Grabner writes:</p>
<blockquote><p><em>It is very important to speed up Page Load Time – don’t get me wrong. It is the initial perceived performance by a user who interacts with your site. But it is not all we need to focus on. Most of the time in modern web applications is spent in JavaScript, DOM Manipulations, XHR Calls and Rendering that happen after the initial page load. Automatic verification against Best Practices won’t work here anymore because we have to analyze individual user actions that do totally different things. The way this will work is to analyze the individual user actions, track performance metrics and automate regression detection based on these measured values.</em></p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/best-practices-for-test-revisited/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5 Link Prefetching</title>
		<link>http://ajaxian.com/archives/html5-link-prefetching</link>
		<comments>http://ajaxian.com/archives/html5-link-prefetching#comments</comments>
		<pubDate>Wed, 22 Sep 2010 11:00:46 +0000</pubDate>
		<dc:creator>Brad Neuberg</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=10280</guid>
		<description><![CDATA[From David Walsh comes a good writeup on the HTML5 link prefetch tag: PLAIN TEXT HTML: &#160; &#60;!-- full page --&#62; &#60;link rel="prefetch" href="http://davidwalsh.name/css-enhancements-user-experience" /&#62; &#160; &#60;!-- just an image --&#62; &#60;link rel="prefetch" href="http://davidwalsh.name/wp-content/themes/walshbook3/images/sprite.png" /&#62; &#160; You use the link tag to do prefetching, setting the rel to "prefetch" and giving the URL to the <a href="http://ajaxian.com/archives/html5-link-prefetching">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://davidwalsh.name"><img class="aligncenter size-full wp-image-10281" title="davidwalsh" src="http://ajaxian.com/wp-content/images/davidwalsh.png" alt="" width="162" height="124" /></a></p>
<p>From <a href="http://davidwalsh.name">David Walsh</a> comes a <a href="http://davidwalsh.name/html5-prefetch">good writeup on the HTML5 link prefetch tag</a>:</p>
<div class="igBar"><a href="javascript:showCodeTxt('html-2');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">HTML:</span>
<div id="html-2">
<div class="html">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- full page --&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/link.html"><span style="color: #000000; font-weight: bold;">&lt;link</span></a> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">"prefetch"</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">"http://davidwalsh.name/css-enhancements-user-experience"</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></a></span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- just an image --&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/link.html"><span style="color: #000000; font-weight: bold;">&lt;link</span></a> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">"prefetch"</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">"http://davidwalsh.name/wp-content/themes/walshbook3/images/sprite.png"</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>You use the link tag to do prefetching, setting the rel to "prefetch" and giving the URL to the resource to prefetch. When should you use link prefetching?</p>
<blockquote><p>Whether prefetching is right for <em>your</em> website is up to you.  Here are a few ideas:</p>
<ul>
<li>When a series of pages is much like a slideshow, load the next 1-3 pages, previous 1-3 pages (assuming they aren't massive).</li>
<li>Loading images to be used on most pages throughout the website.</li>
<li>Loading the next page of the search results on your website.</li>
</ul>
</blockquote>
<p>Some things to know about link prefetching though:</p>
<blockquote><p>A few more notes about link prefetching:</p>
<ul>
<li>Prefetching <em>does</em> work across domains, including pulling cookies from those sites.</li>
<li>Prefetching can throw off website statistics as the user doesn't technically visit a given page.</li>
<li>Mozilla Firefox, currently the only browser to support prefetching, has actually supported prefetching since 2003.</li>
</ul>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/html5-link-prefetching/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>WebPagetest and PageSpeed join up via PageSpeed SDK</title>
		<link>http://ajaxian.com/archives/webpagetest-and-pagespeed-join-up-via-pagespeed-sdk</link>
		<comments>http://ajaxian.com/archives/webpagetest-and-pagespeed-join-up-via-pagespeed-sdk#comments</comments>
		<pubDate>Tue, 07 Sep 2010 17:47:56 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=10218</guid>
		<description><![CDATA[Steve Souders just pointed me to the great news that two great open source performance projects are working well together: Pat Meenan just blogged about Page Speed results now available in Webpagetest. This is a great step toward greater consistency in the world of web performance, something that benefits developers and ultimately benefits web users. <a href="http://ajaxian.com/archives/webpagetest-and-pagespeed-join-up-via-pagespeed-sdk">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p><img src="http://stevesouders.com/images/webpagetest-pagespeed-sm.png" alt="" /></p>
<p>Steve Souders just pointed me to the great news that <a href="http://www.stevesouders.com/blog/2010/09/07/webpagetest-org-and-page-speed/">two great open source performance projects are working well together</a>:</p>
<blockquote><p>Pat Meenan just blogged about <a href="http://blog.patrickmeenan.com/2010/09/page-speed-results-now-available-in.html">Page Speed results now available in Webpagetest</a>. This is a great step toward greater consistency in the world of web performance, something that benefits developers and ultimately benefits web users.</p></blockquote>
<p>The <a href="http://code.google.com/speed/page-speed/">Page Speed SDK</a> gives a path for folks to unify behind standard performance metrics and results. Great work!</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/webpagetest-and-pagespeed-join-up-via-pagespeed-sdk/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Want to pack JS and CSS really well? Convert it to a PNG and unpack it via Canvas</title>
		<link>http://ajaxian.com/archives/want-to-pack-js-and-css-really-well-convert-it-to-a-png-and-unpack-it-via-canvas</link>
		<comments>http://ajaxian.com/archives/want-to-pack-js-and-css-really-well-convert-it-to-a-png-and-unpack-it-via-canvas#comments</comments>
		<pubDate>Sun, 22 Aug 2010 19:30:36 +0000</pubDate>
		<dc:creator>Chris Heilmann</dc:creator>
				<category><![CDATA[Canvas]]></category>
		<category><![CDATA[Front Page]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[buildscript]]></category>
		<category><![CDATA[png]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=10102</guid>
		<description><![CDATA[Jacob Seidelin of nihilogic fame (remember his Super Mario in JavaScript solution) is one of my unsung heroes of JavaScript. His solutions have that Dean Edwards "genius bordering on the bat-sh*t-crazy" touch that make you shake your head in disbelief when they come out but later on become very interesting. One of his posts from <a href="http://ajaxian.com/archives/want-to-pack-js-and-css-really-well-convert-it-to-a-png-and-unpack-it-via-canvas">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p>Jacob Seidelin of <a href="http://blog.nihilogic.dk/">nihilogic</a> fame (remember his <a href="http://www.nihilogic.dk/labs/mario/mario_small_music.htm">Super Mario in JavaScript</a> solution) is one of my unsung heroes of JavaScript. His solutions have that Dean Edwards "genius bordering on the bat-sh*t-crazy" touch that make you shake your head in disbelief when they come out but later on become very interesting. </p>
<p>One of his <a href="http://blog.nihilogic.dk/2008/05/compression-using-canvas-and-png.html">posts from 2008 entitled "Compression using Canvas and PNG-embedded data"</a> had a good idea: if you want to compress JavaScript and CSS you could <a href="http://dean.edwards.name/packer/">reverse engineer a packing algorithm in JavaScript</a> or you could use a lossless packing system that is already in use and supported in browsers. In this case the packed format is PNG and the way to unpack it is by using the canvas API's getImageData() method:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-4');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-4">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> x = <span style="color: #003366; font-weight: bold;">function</span><span style="color:#006600; font-weight:bold;">&#40;</span>z, m, ix <span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color: #009900; font-style: italic;">// image, callback, chunk index</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #003366; font-weight: bold;">var</span> o = <span style="color: #003366; font-weight: bold;">new</span> Image<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; o.<span style="color: #006600;">onload</span> = <span style="color: #003366; font-weight: bold;">function</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> s = <span style="color: #3366CC;">""</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; c = d.<span style="color: #006600;">createElement</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"canvas"</span><span style="color:#006600; font-weight:bold;">&#41;</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; t = c.<span style="color: #006600;">getContext</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"2d"</span><span style="color:#006600; font-weight:bold;">&#41;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; w = o.<span style="color: #006600;">width</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; h = o.<span style="color: #006600;">height</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; c.<span style="color: #006600;">width</span> = c.<span style="color: #006600;">style</span>.<span style="color: #006600;">width</span> = w;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; c.<span style="color: #006600;">height</span> = c.<span style="color: #006600;">style</span>.<span style="color: #006600;">height</span> = h;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; t.<span style="color: #006600;">drawImage</span><span style="color:#006600; font-weight:bold;">&#40;</span>o, <span style="color:#800000;">0</span>, <span style="color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> b = t.<span style="color: #006600;">getImageData</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#800000;">0</span>, <span style="color:#800000;">0</span>, w, h <span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #006600;">data</span>; <span style="color: #009900; font-style: italic;">//b : bucket of data</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">for</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i= <span style="color:#800000;">0</span>; i &lt;b.<span style="color: #006600;">length</span>; i += <span style="color:#800000;">4</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span> b<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006600; font-weight:bold;">&#93;</span>&gt; <span style="color:#800000;">0</span> <span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; s += String.<span style="color: #006600;">fromCharCode</span><span style="color:#006600; font-weight:bold;">&#40;</span>b<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; m<span style="color:#006600; font-weight:bold;">&#40;</span>s, ix<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; o.<span style="color: #006600;">src</span> = z;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>As there are quite some <a href="http://10k.aneventapart.com/">interesting</a> <a href="http://js1k.com/home">competitions</a> going on that need really small JavaScript solutions <a href="http://alexle.net/archives/306">Alex Le</a> took up Jacob's work and wrapped it in a <a href="http://gist.github.com/542462">build script that concatenates, packs and converts to a PNG</a> and unpacks it for the 10K competition with a JavaScript. In the process Alex also found some bug in Internet Explorer 9's canvas implementation as it only reads the first 8192 bytes of a PNG and returns 0 for the others :(.</p>
<p>It is pretty amazing how efficient this way of packing is. What we need to test now is when and if it is worth while to have the unpacking done on the client. Imagine adding your JS and CSS to the end of an image and cropping it in CSS to have all the info you need in an app in a single HTTP request. Let the games begin.</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/want-to-pack-js-and-css-really-well-convert-it-to-a-png-and-unpack-it-via-canvas/feed</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>When does JavaScript trigger reflows and rendering?</title>
		<link>http://ajaxian.com/archives/when-does-javascript-trigger-reflows-and-rendering</link>
		<comments>http://ajaxian.com/archives/when-does-javascript-trigger-reflows-and-rendering#comments</comments>
		<pubDate>Wed, 18 Aug 2010 11:26:21 +0000</pubDate>
		<dc:creator>Michael Mahemoff</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=10098</guid>
		<description><![CDATA[Thomas Fuchs has some good performance things to say reflows and rendering. A video of wikipedia gives you an idea of how much happens when a basic page is rendered: The advice? The important thing is to always remember that reflowing and rendering HTML is the single most expensive operation browsers do. If your page <a href="http://ajaxian.com/archives/when-does-javascript-trigger-reflows-and-rendering">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p>Thomas Fuchs has some good performance things to say <a href="http://mir.aculo.us/2010/08/17/when-does-javascript-trigger-reflows-and-rendering/">reflows and rendering</a>. A video of wikipedia gives you an idea of how much happens when a basic page is rendered:</p>
<p><embed id=VideoPlayback src=http://video.google.com/googleplayer.swf?docid=-5863446593724321515&#038;hl=en&#038;fs=true style=width:400px;height:326px allowFullScreen=true allowScriptAccess=always type=application/x-shockwave-flash> </embed></p>
<p>The advice?</p>
<blockquote><p>The important thing is to always remember that <b>reflowing and rendering HTML is the single most expensive operation browsers do.</b> If your page feels sluggish it’s most likely a problem with rendering. While the easiest way to optimize is to get rid of as many nodes as you can, and trying to have simpler CSS rules, sometimes JavaScript is the culprit.</p></blockquote>
<p>Following changes to the page, a Javascript query like <tt>someElement.offsetHeight</tt> will block execution - to give you the right answer, any pending reflow has to be executed first. So code like this:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-7');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-7">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">someElement.<span style="color: #006600;">style</span>.<span style="color: #006600;">fontSize</span> = <span style="color: #3366CC;">"14px"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000066; font-weight: bold;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span>someElement.<span style="color: #006600;">offsetHeight</span>&gt;<span style="color:#800000;">100</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color: #009900; font-style: italic;">/* ... */</span> <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">someElement.<span style="color: #006600;">style</span>.<span style="color: #006600;">paddingLeft</span> = <span style="color: #3366CC;">"20px"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000066; font-weight: bold;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span>someElement.<span style="color: #006600;">offsetWidth</span>&gt;<span style="color:#800000;">100</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color: #009900; font-style: italic;">/* ... */</span> <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>could be twice as fast if you wrote it like this:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-8');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-8">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">someElement.<span style="color: #006600;">style</span>.<span style="color: #006600;">fontSize</span> = <span style="color: #3366CC;">"14px"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">someElement.<span style="color: #006600;">style</span>.<span style="color: #006600;">paddingLeft</span> = <span style="color: #3366CC;">"20px"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000066; font-weight: bold;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span>someElement.<span style="color: #006600;">offsetHeight</span>&gt;<span style="color:#800000;">100</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color: #009900; font-style: italic;">/* ... */</span> <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000066; font-weight: bold;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span>someElement.<span style="color: #006600;">offsetWidth</span>&gt;<span style="color:#800000;">100</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color: #009900; font-style: italic;">/* ... */</span> <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>because there are two reflows in the first example, and only one in the second.</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/when-does-javascript-trigger-reflows-and-rendering/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Canvas Color Cycling</title>
		<link>http://ajaxian.com/archives/canvas-color-cycling</link>
		<comments>http://ajaxian.com/archives/canvas-color-cycling#comments</comments>
		<pubDate>Tue, 27 Jul 2010 00:21:55 +0000</pubDate>
		<dc:creator>Michael Mahemoff</dc:creator>
				<category><![CDATA[Canvas]]></category>
		<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=9881</guid>
		<description><![CDATA[Interest in Canvas, as well as mobile apps, has led to a renaissance of old-school 8-bit graphics. Joe Huckaby of Effect Games has been playing around with color cycling, leading to some stunning effects. Anyone remember Color cycling from the 90s? This was a technology often used in 8-bit video games of the era, to <a href="http://ajaxian.com/archives/canvas-color-cycling">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.effectgames.com/demos/canvascycle/?sound=0"><img src="http://ajaxian.com/wp-content/images/Canvas-Cycle_-True-8-bit-Color-Cycling-with-HTML5.jpg" alt="" title="Canvas Cycle_ True 8-bit Color Cycling with HTML5" width="525" height="421" class="alignnone size-full wp-image-9880" /></a></p>
<p>Interest in Canvas, as well as mobile apps, has led to a renaissance of old-school 8-bit graphics. Joe Huckaby of <a href="http://www.effectgames.com/">Effect Games</a> has been playing around with color cycling, leading to some <a href="http://www.effectgames.com/demos/canvascycle/?sound=0">stunning effects</a>.</p>
<blockquote><p>
Anyone remember <a href="http://en.wikipedia.org/wiki/Color_cycling" class="dx_external_link" target="_blank">Color cycling</a> from the 90s?  This was a technology often used in 8-bit video games of the era, to achieve interesting visual effects by cycling (shifting) the color palette.  Back then video cards could only render 256 colors at a time, so a palette of selected colors was used.  But the programmer could change this palette at will, and all the onscreen colors would instantly change to match.  It was fast, and took virtually no memory.
</p></blockquote>
<p>There's a neat optimization going on here too: instead of clearing and redrawing the entire scene with each frame, he only updates the pixels that change:</p>
<blockquote><p>
In order to achieve fast frame rates in the browser, I had to get a little crazy in the engine implementation. Rendering a 640x480 indexed image on a 32-bit RGB canvas means walking through and drawing 307,200 pixels per frame, in JavaScript. That's a very big array to traverse, and some browsers just couldn't keep up. To overcome this, I pre-process the images when they are first loaded, and grab the pixels that reference colors which are animated (i.e. are part of cycling sets in the palette). Those pixel X/Y offsets are stored in a separate, smaller array, and thus only the pixels that change are refreshed onscreen. This optimization trick works so well, that the thing actually runs at a pretty decent speed on my iPhone 3GS and iPad!
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/canvas-color-cycling/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>IE9 gets a Web Timing API to measure performance</title>
		<link>http://ajaxian.com/archives/ie9-gets-a-web-timing-api-to-measure-performance</link>
		<comments>http://ajaxian.com/archives/ie9-gets-a-web-timing-api-to-measure-performance#comments</comments>
		<pubDate>Wed, 30 Jun 2010 08:15:36 +0000</pubDate>
		<dc:creator>Chris Heilmann</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[ie9]]></category>
		<category><![CDATA[webtiming]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=9734</guid>
		<description><![CDATA[Web site performance is a very important topic. We should not let our end users wait for our sites and optimizing them for load time and rendering can save us thousands of dollars in traffic. There is a lot of great content out there on performance (spearheaded by Yahoo a few years back). When it <a href="http://ajaxian.com/archives/ie9-gets-a-web-timing-api-to-measure-performance">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p>Web site performance is a very important topic. We should not let our end users wait for our sites and optimizing them for load time and rendering can save us thousands of dollars in traffic. There is a lot of great content out there on performance (spearheaded by <a href="http://developer.yahoo.com/performance/">Yahoo</a> a few years back). When it comes to testing the performance after the page has loaded though there is a lot of things you can do wrong as you need to test things with timers and hope nothing else happening to your test machine interferes with your results. </p>
<p>The IE9 team wants to make it easier for developers and added a new Web Timing API in the browser. <a href="http://dev.w3.org/2006/webapi/WebTiming/">Web Timing</a> is a W3C working draft and the API implemented the NavigationTiming part of the spec in <code>window.msPerformance.timing</code> and offers you a few sets of information without having to hack your own solution:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-11');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-11">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">interface MSPerformanceTiming<span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong navigationStart;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong fetchStart;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong unloadStart;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong unloadEnd;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong domainLookupStart;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong domainLookupEnd;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong connectStart;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong connectEnd;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong requestStart;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong requestEnd;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong responseStart;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong responseEnd;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong domLoading;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong domInteractive;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong domContentLoaded;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong domComplete;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong loadStart;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong loadEnd;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong firstPaint;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong fullyLoaded;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>You have even more granular control in <code>timingMeasures</code></p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-12');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-12">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">interface MSPerformanceTimingMeasures<span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong navigation;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong fetch;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong unload;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong domainLookup;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong connect;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong request;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong response;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong domLoading;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong domInteractive;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong domContentLoaded;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong domComplete;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong load;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong firstPaint;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;readonly attribute unsigned longlong fullyLoaded;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>Read <a href="http://blogs.msdn.com/b/ie/archive/2010/06/28/measuring-web-page-performance.aspx">the original post on MSDN</a> and <a href="http://ie.microsoft.com/testdrive/Performance/msPerformance/Default.html">check out the demo on IE Test Drive</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/ie9-gets-a-web-timing-api-to-measure-performance/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JSKB: JavaScript Knowledge Base. Shrinking your code via BrowserScope and Caja</title>
		<link>http://ajaxian.com/archives/jskb-javascript-knowledge-base-shrinking-your-code-via-browserscope-and-caja</link>
		<comments>http://ajaxian.com/archives/jskb-javascript-knowledge-base-shrinking-your-code-via-browserscope-and-caja#comments</comments>
		<pubDate>Wed, 16 Jun 2010 13:16:59 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=9608</guid>
		<description><![CDATA[We have a screwed up tensions on the Web. The size of your source code really matters for performance. The larger your .js.... the longer it takes it to get down the pipe. This has a perverse incentive to write terse uncommented code. Add to this the problem of having to work cross browser, and <a href="http://ajaxian.com/archives/jskb-javascript-knowledge-base-shrinking-your-code-via-browserscope-and-caja">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p>We have a screwed up tensions on the Web. The size of your source code really matters for performance. The larger your .js.... the longer it takes it to get down the pipe. This has a perverse incentive to write terse uncommented code. Add to this the problem of having to work cross browser, and having to do so all at runtime, and you end up shipping a ton of code to browsers that will never touch it.</p>
<p>This is where Mike Samuel of Caja, and Lindsey Simon of Browserscope come in. They have a plan to <a href="http://googlecode.blogspot.com/2010/06/reversing-code-bloat-with-javascript.html">help reverse code bloat with JavaScript</a>:</p>
<blockquote><p>
Lots of compilers (incl. (JSMin, Dojo, YUI, Closure, Caja) remove unnecessary code from JavaScript to make the code you ship smaller. They seem like a natural place to address this problems. Optimization is just taking into account the context that code is going to run in to improve it; giving compilers information about browsers will help them avoid shipping code to support marginal browsers to modern browsers.</p>
<p>The JavaScript Knowledge Base (JSKB) on <a href="http://www.browserscope.org/jskb/test">browserscope.org</a> seeks to systematically capture this information in a way that compilers can use.<br />
It collects facts about browsers using JavaScript snippet. The JavaScript code <code>(!!window.JSON &#038;& typeof window.JSON.stringify === 'function')</code> is true if JSON is defined. JSKB knows that this is true for Firefox 3.5 but not Netscape 2.0.</p>
<p><a href="http://caja.appspot.com/tools/index">Caja Web Tools</a> includes a code optimizer that uses these facts. If it sees code like <code>if (typeof JSON.stringify !== 'function') { /* lots of code */ }</code> it knows that the body will never be executed on Firefox 3.5, and can optimize it out. The key here is that the developer writes feature tests, not version tests, and as browsers roll out new features, JSKB captures that information, letting compilers produce smaller code for that browser.</p>
<p>The Caja team just released Caja Web Tools, which already uses JSKB to optimize code. We hope that other JavaScript compilers will adopt these techniques. If you're working on a JavaScript optimizer, take a look at our JSON APIs to get an idea of what the JSKB contains.
</p></blockquote>
<p>You can <a href="http://google-caja.googlecode.com/svn/trunk/doc/html/jskb.html">see graphically how this works</a> and learn more about how browser detection info is packaged:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-14');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-14">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #3366CC;">"!!this.window !== 'undefined' &amp;&amp; this === window"</span>: <span style="color: #003366; font-weight: bold;">true</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #3366CC;">"typeof addEventListener"</span>: <span style="color: #3366CC;">"function"</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #3366CC;">"typeof attachEvent"</span>: <span style="color: #3366CC;">"undefined"</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #3366CC;">"typeof document.body.outerHTML"</span>: <span style="color: #3366CC;">"undefined"</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>Definitely feels like there is a lot of room to do more with a compilation step that only sends down the right JS for the given browser.</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/jskb-javascript-knowledge-base-shrinking-your-code-via-browserscope-and-caja/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Y.preload: load before execution</title>
		<link>http://ajaxian.com/archives/y-preload-load-before-execution</link>
		<comments>http://ajaxian.com/archives/y-preload-load-before-execution#comments</comments>
		<pubDate>Tue, 15 Jun 2010 11:13:24 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=9578</guid>
		<description><![CDATA[Caridy Patino has posted on a new YUI3 module for preloading of content, implementing Stoyan's ideas. You can now strap on some preloading goodness to your YUI application: PLAIN TEXT JAVASCRIPT: &#160; YUI&#40;&#123; &#160; &#160; //Last Gallery Build of this module &#160; &#160; gallery: 'gallery-2010.05.05-19-39' &#125;&#41;.use&#40;'gallery-preload', function&#40;Y&#41; &#123; &#160; Y.preload &#40;&#91; &#160; &#160; 'http://tools.w3clubs.com/pagr2/1.sleep.expires.png', &#160; <a href="http://ajaxian.com/archives/y-preload-load-before-execution">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p>Caridy Patino has posted on a new <a href="http://www.yuiblog.com/blog/2010/06/10/gallery-preload/">YUI3 module for preloading of content</a>, implementing <a href="http://www.phpied.com/preload-cssjavascript-without-execution/">Stoyan's ideas</a>.</p>
<p>You can now strap on some preloading goodness to your YUI application:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-18');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-18">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">YUI<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//Last Gallery Build of this module</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; gallery: <span style="color: #3366CC;">'gallery-2010.05.05-19-39'</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #006600;">use</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">'gallery-preload'</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color:#006600; font-weight:bold;">&#40;</span>Y<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; Y.<span style="color: #006600;">preload</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #3366CC;">'http://tools.w3clubs.com/pagr2/1.sleep.expires.png'</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #3366CC;">'http://tools.w3clubs.com/pagr2/1.sleep.expires.js'</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #3366CC;">'http://tools.w3clubs.com/pagr2/1.sleep.expires.css'</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>As well as just loading away, you can also wait for the user to focus on something on the page before reloading:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-19');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-19">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">Y.<span style="color: #006600;">on</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"focus"</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Y.<span style="color: #006600;">preload</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">'http://tools.w3clubs.com/pagr2/2.sleep.expires.png'</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">'http://tools.w3clubs.com/pagr2/2.sleep.expires.js'</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">'http://tools.w3clubs.com/pagr2/2.sleep.expires.css'</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span>, <span style="color: #3366CC;">".myform input.query"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>Or, to take it even further, only preload if the <a href="http://yuilibrary.com/gallery/show/idletimer">user is probably idle</a>:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-20');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-20">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">Y.<span style="color: #006600;">preloadOnIdle</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #3366CC;">'http://tools.w3clubs.com/pagr2/3.sleep.expires.png'</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #3366CC;">'http://tools.w3clubs.com/pagr2/3.sleep.expires.js'</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #3366CC;">'http://tools.w3clubs.com/pagr2/3.sleep.expires.css'</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#006600; font-weight:bold;">&#93;</span>, <span style="color:#800000;">100</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color: #009900; font-style: italic;">// ms</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>Nicely packaged.</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/y-preload-load-before-execution/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How fast does FIFA.com score a goal?</title>
		<link>http://ajaxian.com/archives/how-fast-does-fifa-com-score-a-goal</link>
		<comments>http://ajaxian.com/archives/how-fast-does-fifa-com-score-a-goal#comments</comments>
		<pubDate>Fri, 11 Jun 2010 17:30:58 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=9569</guid>
		<description><![CDATA[It's the World Cup again. Being a Brit, I am on tender hooks with the first England game coming up tomorrow with the USA. A family feud for me. We start to see great microsites such as the Twitter @worldcup site, and as we think about what the fastest goal will be... what about the <a href="http://ajaxian.com/archives/how-fast-does-fifa-com-score-a-goal">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://twitter.com/worldcup"><img src="http://ajaxian.com/wp-content/images/twitterworldcup.png" alt="" title="twitterworldcup" width="480" height="275" class="alignnone size-full wp-image-9571" /></a></p>
<p>It's the World Cup again. Being a Brit, I am on tender hooks with the first England game coming up tomorrow with the USA. A family feud for me. We start to see great microsites such as the <a href="http://twitter.com/worldcup">Twitter @worldcup site</a>, and as we think about what the fastest goal will be... what about the fastest website?</p>
<p>Dynatrace had some fun and did a <a href="http://blog.dynatrace.com/2010/06/04/hands-on-guide-verifying-fifa-world-cup-web-site-against-performance-best-practices/">performance test on FIFA.com</a>:</p>
<blockquote>
<ul>
<li><em><strong>Time to First Impression/Drawing</strong><strong>: </strong></em><strong><span style="color: #ff0000;">3.74s</span></strong>
<ul>
<li>Analysis: so it takes almost 4s until the user sees a visual indication of the page load &#8211; that is definitely too long and should be improved</li>
<li>Recommendation: <span style="color: #339966;"><strong>&lt; 1s</strong></span> is great. <strong><span style="color: #ff6600;">&lt;2.5s</span></strong> is acceptable</li>
</ul>
</li>
<li><em><strong>Time to onLoad</strong><strong>: </strong></em><strong><span style="color: #ff0000;">8.25s</span></strong>
<ul>
<li>Analysis: it takes the browser 8.25 to download the initial document plus all referenced objects before it triggers the onLoad event that allows JavaScript to modify the page after it has been loaded &#8211; again &#8211; much too slow as nobody likes to wait 8s until the content is loaded</li>
<li>Recommendation: <span style="color: #339966;"><strong>&lt; 2s</strong></span> is great. <strong><span style="color: #ff6600;">&lt;4s</span></strong> is acceptable</li>
</ul>
</li>
<li><em><strong>Time to Fully Loaded: </strong></em><strong><span style="color: #ff0000;">8.6s</span></strong>
<ul>
<li>the page loads additional resources triggered by JavaScript onLoad handlers. I consider the page as fully loaded when all these additional requests are downloaded. I guess I don&#8217;t need to mention that 8.6s is not fast <img src='http://blog.dynatrace.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </li>
<li>Recommendations: <span style="color: #339966;"><strong>&lt; 2s</strong></span> is great. <span style="color: #ff6600;"><strong>&lt;5s</strong> </span>is acceptable</li>
</ul>
</li>
<li><em><strong>Number of HTTP Requests: </strong></em><strong><span style="color: #ff0000;">201</span></strong>
<ul>
<li>Analysis: 201 &#8211; that&#8217;s a lot of  elements for a single page. We have seen many images that are the main  contributor to this load. My first thought on this -&gt; let&#8217;s seen how  we can reduce this number by e.g.: merging files (more details later)</li>
<li>Recommendations: <strong><span style="color: #339966;">&lt; 20</span></strong> is great. <strong><span style="color: #ff6600;">&lt; 100</span></strong> is acceptable (This one is a hard recommendation as it really depends on the type of website &#8211; but &#8211; it is a good start to measure this KPI)</li>
</ul>
</li>
<li><em><strong>Number and Impact of HTTP Redirects:<span style="color: #ff0000;"> </span></strong></em><strong><span style="color: #ff0000;">1/1.44s</span></strong>
<ul>
<li>Analysis: This is a very expensive and it seems unnecessary redirect from http://www.fifa.com/worldcup to http://www.fifa.com/worldcup/</li>
<li>Recommendations: <span style="color: #339966;"><strong>0</strong></span>. Avoid Redirects whenever possible</li>
</ul>
</li>
<li><strong><em>Number and Impact of HTTP 400&#8217;s:</em> <span style="color: #ff0000;">1/0.71s</span></strong>
<ul>
<li>Analysis: There seems to be a javascript file that results in a HTTP 403 Forbidden Response and takes a total of 0.71s.</li>
<li>Recommendations: <span style="color: #339966;"><strong>0</strong></span>. Avoid any 400&#8217;s and 500&#8217;s</li>
</ul>
</li>
<li><em><strong>Size of JavaScript/CSS/Images: </strong></em><strong><span style="color: #ff0000;">~370kb/220kb/890kb</span></strong>
<ul>
<li>Analysis: Size of individual mime types is always a good indicator and helps to compare to other sites and other builds. 370kb of JavaScript and 220kb of CSS can probably reduced to a smaller size by using certain minimization techniques or by getting rid of unused code or styles</li>
<li>Recommendations: It is hard to give a definite threshold value. Keep in mind that these files need to be downloaded and parsed by the browser. The more content there is the more work on the browser. The goal must be to remove all information that is not needed for the current page. I often see developers packing everything in a huge global .js file. That might be a good practice but too often only a fraction of this code is actually used by the end-user. It is better to load what needs to be loaded in the beginning and delay load additional content when really needed</li>
</ul>
</li>
<li><em><strong>Max/Average Wait Time: </strong></em><strong><span style="color: #ff0000;">4.31s/1.9s</span></strong>
<ul>
<li>Analysis: this means that resources have to wait up to 4.3s to be downloaded and that they have to wait 1.9s on average. This is way to much and can be reduced by either reducing the number of resources or by spreading them on multiple domains (<a href="http://www.stevesouders.com/blog/2009/05/12/sharding-dominant-domains/" target="_blank">Domain Sharding</a>) in order to allow the browser to use more physical connections.</li>
<li>Recommendations: <span style="color: #339966;"><strong>&lt; 20ms</strong></span> is good. <span style="color: #ff6600;"><strong>&lt; 50ms</strong> </span>is acceptable (as you can see &#8211; we are FAR OFF these numbers in this example)</li>
</ul>
</li>
<li><em><strong>Single Resource Domains: </strong></em><strong><span style="color: #ff0000;">1</span></strong>
<ul>
<li>Analysis: from the timeline we can also see that there is one domain that only serves a single resource. In this particular case it seems to be serving an ad. We can assume that this might not be changeable but this KPI is a good indicator on whether it is worth paying the cost of a DNS Lookup and Connect if we only download a single resource from a domain</li>
<li>Recommendations: <span style="color: #339966;"><strong>0</strong></span>. Try to avoid single resource domains. It is not always possible &#8211; but do it if you can</li>
</ul>
</li>
</ul>
<p>The KPI&#8217;s tell me that the page is way too slow &#8211; especially the Full Page Load Time of 8.6s needs to be optimized. With the KPI&#8217;s we can already think about certain areas to focus on, e.g.: reducing the network roundtrips or minimizing content size. But there is much more. Let&#8217;s have a closer look into 4 different areas.</p>
</blockquote>
<p>Then they get to analysis on the network, caching, JavaScript execution, and is all adds up to an F :/</p>
<blockquote>
<ul>
<li>Browser Caching: <b>F</b> – 175 images have a short expires header, 4 have a header in the past
</li>
<li>Network: <b>F</b> – 201 Requests in total, 1 Redirect, 1 HTTP 400, duplicated image requests on different domains
</li>
<li>Server-Side: <b>C</b> - 10 App-Server Requests with a total of 3.6s -> analyze server-side processing
</li>
<li>JavaScript: <b>D</b> - Use CSS Lookups by ID instead of Class Name
</li>
</ul>
</blockquote>
<p><a href="http://www.google.com/search?hl=en&amp;q=worldcup&amp;aq=f&amp;aqi=&amp;aql=&amp;oq=&amp;gs_rfai="><img src="http://ajaxian.com/wp-content/images/goooooal.png" alt="" title="goooooal" width="334" height="82" class="alignnone size-full wp-image-9570" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/how-fast-does-fifa-com-score-a-goal/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Facebook has a BigPipe to smoke competitors on performance</title>
		<link>http://ajaxian.com/archives/facebook-has-a-bigpipe-to-smoke-competitors-on-performance</link>
		<comments>http://ajaxian.com/archives/facebook-has-a-bigpipe-to-smoke-competitors-on-performance#comments</comments>
		<pubDate>Thu, 10 Jun 2010 11:10:29 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=9550</guid>
		<description><![CDATA[Remember a time when you would make fun of Facebook for having such poor performance? You would see 400 scripts that would be loading, some of which that would have code for no reason. That was in the distant past now. Makinde Adeagbo gave that great talk at JSConf about the copious amount of code <a href="http://ajaxian.com/archives/facebook-has-a-bigpipe-to-smoke-competitors-on-performance">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p>Remember a time when you would make fun of Facebook for having such poor performance? You would see 400 scripts that would be loading, some of which that would have code for no reason. That was in the distant past now. </p>
<p>Makinde Adeagbo gave <a href="http://ajaxian.com/archives/facebook-javascript-jsconf">that great talk at JSConf</a> about the copious amount of code they were able to delete while speeding up the site. With folks like him and Tom Occhino on the case, you know good things are happening.</p>
<p>If you do a view source on the Facebook home page these days, you see a lot of this:</p>
<div class="igBar"><a href="javascript:showCodeTxt('html-22');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">HTML:</span>
<div id="html-22">
<div class="html">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script&gt;</span></a></span>big_pipe = new BigPipe(null, 4, null, true);<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script&gt;</span></a></span>big_pipe.onPageletArrive({&quot;id&quot;:&quot;pagelet_intentional_stream&quot;,&quot;phase&quot;:1,&quot;is_last&quot;:false,&quot;append&quot;:false,&quot;bootloadable&quot;:{&quot;ufi-tracking-js&quot;:[&quot;F+B8D&quot;,&quot;CDYbm&quot;,&quot;A5j5z&quot;,&quot;3NVRu&quot;],&quot;UIIntentionalStreamRefresh&quot;:[&quot;F+B8D&quot;,&quot;CDYbm&quot;,&quot;EMOa3&quot;,&quot;zwScZ&quot;,&quot;fWhta&quot;,&quot;EzjZW&quot;]},&quot;css&quot;:[&quot;jFmkz&quot;,&quot;z9ULo&quot;,&quot;lShFv&quot;,&quot;bh3tE&quot;,&quot;1AZL5&quot;,&quot;OxGjK&quot;],&quot;js&quot;:[&quot;F+B8D&quot;,&quot;CDYbm&quot;,&quot;A5j5z&quot;,&quot;fWhta&quot;,&quot;uUXWA&quot;],&quot;resource_map&quot;:{&quot;fWhta&quot;:{&quot;name&quot;:&quot;js\/a62kak05d08cgw8o.pkg.js&quot;,&quot;type&quot;:&quot;js&quot;,&quot;permanent&quot;:false,&quot;src&quot;:&quot;http:\/\/static.ak.fbcdn.net\/rsrc.php\/z1AQ7\/hash\/qkma6pho.js&quot;},&quot;lShFv&quot;:{&quot;name&quot;:&quot;css\/sprite\/autogen\/e6h3iy.css&quot;,&quot;type&quot;:&quot;css&quot;,&quot;permanent&quot;:false,&quot;src&quot;:&quot;http:\/\/static.ak.fbcdn.net\/rsrc.php\/zALI5\/hash\/cngu73tz.css&quot;},&quot;bh3tE&quot;:{&quot;name&quot;:&quot;css\/sprite\/autogen\/3jkv60.css&quot;,&quot;type&quot;:&quot;css&quot;,&quot;permanent&quot;:false,&quot;src&quot;:&quot;http:\/\/static.ak.fbcdn.net\/rsrc.php\/z4M49\/hash\/7wet04gi.css&quot;},&quot;OxGjK&quot;:{&quot;name&quot;:&quot;css\/1b9p1ur0qpog8cgw.pkg.css&quot;,&quot;type&quot;:&quot;css&quot;,&quot;permanent&quot;:true,&quot;src&quot;:&quot;http:\/\/static.ak.fbcdn.net\/rsrc.php\/zC6TL\/hash\/1quse983.css&quot;},&quot;3NVRu&quot;:{&quot;name&quot;:&quot;js\/ufi\/tracking.js&quot;,&quot;type&quot;:&quot;js&quot;,&quot;permanent&quot;:false,&quot;src&quot;:&quot;http:\/\/static.ak.fbcdn.net\/rsrc.php\/z8CIM\/hash\/7c5lvnd6.js&quot;},&quot;EMOa3&quot;:{&quot;name&quot;:&quot;js\/lib\/util\/user_activity.js&quot;,&quot;type&quot;:&quot;js&quot;,&quot;permanent&quot;:false,&quot;src&quot;:&quot;http:\/\/static.ak.fbcdn.net\/rsrc.php\/z2MJ2\/hash\/7q88hxyg.js&quot;},&quot;EzjZW&quot;:{&quot;name&quot;:&quot;js\/stream\/UIIntentionalStreamRefresh.js&quot;,&quot;type&quot;:&quot;js&quot;,&quot;permanent&quot;:false,&quot;src&quot;:&quot;http:\/\/static.ak.fbcdn.net\/rsrc.php\/z7LZY\/hash\/5vjds43u.js&quot;}},&quot;requires&quot;:[],&quot;provides&quot;:[&quot;pagelet_controller::home_intentional_stream&quot;],&quot;onload&quot;:[&quot;window.__UIControllerRegistry[\&quot;c4c0ebcac26d1c478579b3\&quot;] = new UIPagelet(\&quot;c4c0ebcac26d1c478579b3\&quot;, \&quot;\\\/pagelet\\\/home\\\/intentional_stream.php\&quot;, {\&quot;is_multi_stream\&quot;:true,\&quot;is_prefetch\&quot;:false,\&quot;first_load\&quot;:null}, {});; ;&quot;,&quot;share_data={max_recipients:20}&quot;,&quot;window.__UIControllerRegistry[\&quot;c4c0ebcac36a540af71b6d\&quot;] = new UIIntentionalStream($(\&quot;c4c0ebcac36a540af71b6d\&quot;), \&quot;nile\&quot;, 1276034077, 1276032692, 5, \&quot;lf\&quot;, 10, 0, \&quot;[]\&quot;, \&quot;[]\&quot;, false, 300);; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">//..</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>This is BigPipe, and it is <a href="http://www.facebook.com/notes/facebook-engineering/bigpipe-pipelining-web-pages-for-high-performance/389414033919">explained by this Facebook Note</a>:</p>
<blockquote><p>
To exploit the parallelism between web server and browser, BigPipe first breaks web pages into multiple chunks called pagelets. Just as a pipelining microprocessor divides an instruction’s life cycle into multiple stages (such as “instruction fetch”, “instruction decode”, “execution”, “register write back” etc.), BigPipe breaks the page generation process into several stages:</p>
<ol>
<li>Request parsing: web server parses and sanity checks the HTTP request.
</li>
<li>Data fetching: web server fetches data from storage tier.
</li>
<li>Markup generation: web server generates HTML markup for the response.
</li>
<li>Network transport: the response is transferred from web server to browser.
</li>
<li>CSS downloading: browser downloads CSS required by the page.
</li>
<li>DOM tree construction and CSS styling: browser constructs DOM tree of the document, and then applies CSS rules on it.
</li>
<li>JavaScript downloading: browser downloads JavaScript resources referenced by the page.
</li>
<li>JavaScript execution: browser executes JavaScript code of the page.
</li>
</ol>
<p>The first three stages are executed by the web server, and the last four stages are executed by the browser. Each pagelet must go through all these stages sequentially, but BigPipe enables several pagelets to be executed simultaneously in different stages.</p>
<p><a href="http://www.facebook.com/photo.php?pid=3988037&#038;op=1&#038;view=all&#038;subj=389414033919&#038;aid=-1&#038;auser=0&#038;oid=389414033919&#038;id=9445547199"><img src="http://sphotos.ak.fbcdn.net/hphotos-ak-snc3/hs539.snc3/30586_396762827199_9445547199_3988037_2012363_n.jpg" width="480"/></a></p>
<p>The picture above uses Facebook’s home page as an example to demonstrate how web pages are decomposed into pagelets. The home page consists of several pagelets: “composer pagelet”, “navigation pagelet”, “news feed pagelet”, “request box pagelet”, “ads pagelet”, “friend suggestion box” and “connection box”, etc. Each of them is independent of each. When the "navigation pagelet" is displayed to the user, the "news feed pagelet" can still be being generated at the server.</p>
<p>In BigPipe, the life cycle of a user request is the following: The browser sends an HTTP request to web server. After receiving the HTTP request and performing some sanity check on it, web server immediately sends back an unclosed HTML document that includes an HTML <head> tag and the first part of the <body> tag. The <head> tag includes BigPipe’s JavaScript library to interpret pagelet responses to be received later. In the <body> tag, there is a template that specifies the logical structure of page and the placeholders for pagelets.</p>
<p><b>Performance results</b></p>
<p>The graph below shows the performance data comparing the 75th percentile user perceived latency for seeing the most important content in a page (e.g. news feed is considered the most important content on Facebook home page) on traditional model and BigPipe. The data is collected by loading Facebook home page 50 times using browsers with cold browser cache. The graph shows that BigPipe reduces user perceived latency by half in most browsers.</p>
<p><img src="http://hphotos-snc3.fbcdn.net/hs539.snc3/30586_396772147199_9445547199_3988332_604391_n.jpg"/><br />
</body></head></body></head></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/facebook-has-a-bigpipe-to-smoke-competitors-on-performance/feed</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Fuchs-ing an iPad HTML5 app for performance</title>
		<link>http://ajaxian.com/archives/fuchs-ing-an-ipad-html5-app-for-performance</link>
		<comments>http://ajaxian.com/archives/fuchs-ing-an-ipad-html5-app-for-performance#comments</comments>
		<pubDate>Fri, 04 Jun 2010 16:45:07 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=9513</guid>
		<description><![CDATA[Thomas has a great post today on how he took the lovely Every Time Zone HTML5 app for the iPad and went deep to make it perform smoothly to match its beauty. He has documented what he did: Canvas optimizations over images: Thomas found out that using -webkit-gradient produces images which slow down the rendering <a href="http://ajaxian.com/archives/fuchs-ing-an-ipad-html5-app-for-performance">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p><img src="http://mir.aculo.us/wp-content/uploads/2010/06/etzipad.png" style="padding:8px; float:right"/></p>
<p>Thomas has a <a href="http://mir.aculo.us/2010/06/04/making-an-ipad-html5-app-making-it-really-fast/">great post today</a> on how he took the lovely <a href="http://everytimezone.com/">Every Time Zone</a> HTML5 app for the iPad and went deep to make it perform smoothly to match its beauty.</p>
<p>He has documented what he did:</p>
<ul>
<li>Canvas optimizations over images: Thomas found out that using <code>-webkit-gradient</code> produces images which slow down the rendering on the iPad itself. His optimization was to use a <code>&lt;canvas&gt;</code> and only repaint what was needed.
</li>
<li>Avoid text-shadow &#038; box-shadow: Great. but slow
</li>
<li>Hardware-acceleration is quite new… and buggy (aside: he called out some new scripty2 hw accel demos coming maybe as soon as next week!)
</li>
<li>touch events fire before click events (use <code>element[supportsTouch ? 'ontouchmove' : 'onmousemove'] = function(){}</code>)
</li>
<li>Avoid opacity: Found that it can interfere with hw acceleration
</li>
<li>Don't use a js lib unless you need it. Every bit matters
</li>
</ul>
<p>Maybe iPhone OS 4 will change the characteristics.... but who knows. Good stuff.</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/fuchs-ing-an-ipad-html5-app-for-performance/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ShowSlow monitors your YSlow and Google Page Speed scores</title>
		<link>http://ajaxian.com/archives/showslow-monitors-your-yslow-and-google-page-speed-scores</link>
		<comments>http://ajaxian.com/archives/showslow-monitors-your-yslow-and-google-page-speed-scores#comments</comments>
		<pubDate>Tue, 01 Jun 2010 11:25:18 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=9426</guid>
		<description><![CDATA[Show Slow has a great new feature. Sergey Chernyshev and team now monitor your YSlow and Page Speed stats: Show Slow will fire YSlow and Page Speed at your site and collect statistics on a daily basis so you can just sit back and enjoy the graphs! You can also check out the Alex 100 <a href="http://ajaxian.com/archives/showslow-monitors-your-yslow-and-google-page-speed-scores">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.showslow.com/">Show Slow</a> has a great new feature. Sergey Chernyshev and team now <a href="http://www.showslow.com/my.php">monitor your YSlow and Page Speed stats</a>: </p>
<blockquote><p>
Show Slow will fire YSlow and Page Speed at your site and collect statistics on a daily basis so you can just sit back and enjoy the graphs!
</p></blockquote>
<p>You can also check out the <a href="http://www.showslow.com/list.php?id=alexa">Alex 100</a> scores.</p>
<p>Steve Souders <a href="http://twitter.com/souders/status/14888903513">said</a>:</p>
<blockquote><p>
Reassuring that the correlation coefficient of Alexa 100 YSlow and Page Speed scores is 0.83!
</p></blockquote>
<p>A very nice utility. Why wouldn't you monitor your scores?</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/showslow-monitors-your-yslow-and-google-page-speed-scores/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Canvas optimization tip: Get image data as infrequently as possible</title>
		<link>http://ajaxian.com/archives/canvas-image-data-optimization-tip</link>
		<comments>http://ajaxian.com/archives/canvas-image-data-optimization-tip#comments</comments>
		<pubDate>Thu, 27 May 2010 12:01:46 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Canvas]]></category>
		<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=9372</guid>
		<description><![CDATA[We have learned to touch the DOM as little as possible for performance sakes. Batch up changes, and do one call to innerHTML say. Talk over the evil boundary of the DOM as infrequently as possible. Well, Selim Arsever has found a similar tip for Canvas that caused a ~40% performance improvement on some of <a href="http://ajaxian.com/archives/canvas-image-data-optimization-tip">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p>We have learned to touch the DOM as little as possible for performance sakes. Batch up changes, and do one call to innerHTML say. Talk over the evil boundary of the DOM as infrequently as possible.</p>
<p>Well, Selim Arsever has <a href="http://www.onaluf.org/en/entry/13">found a similar tip for Canvas</a> that caused a ~40% performance improvement on some of his code. He had an example that did pixel twiddling, looking like:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-25');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-25">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">canvas = document.<span style="color: #006600;">getElementById</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"canvas"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">context = canvas.<span style="color: #006600;">getContext</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"2d"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">image = context.<span style="color: #006600;">getImageData</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;">0</span>, <span style="color:#800000;">0</span>, SCREEN_WIDTH, SCREEN_HEIGHT<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> pixels = SCREEN_WIDTH*SCREEN_HEIGHT;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000066; font-weight: bold;">while</span><span style="color:#006600; font-weight:bold;">&#40;</span>--pixels<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;image.<span style="color: #006600;">data</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;">4</span>*i+<span style="color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span> = r; <span style="color: #009900; font-style: italic;">// Red value</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;image.<span style="color: #006600;">data</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;">4</span>*i+<span style="color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span> = g; <span style="color: #009900; font-style: italic;">// Green value</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;image.<span style="color: #006600;">data</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;">4</span>*i+<span style="color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#93;</span> = b; <span style="color: #009900; font-style: italic;">// Blue value</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;image.<span style="color: #006600;">data</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;">4</span>*i+<span style="color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#93;</span> = a; <span style="color: #009900; font-style: italic;">// Alpha value</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">context.<span style="color: #006600;">putImageData</span><span style="color:#006600; font-weight:bold;">&#40;</span>image, <span style="color:#800000;">0</span>, <span style="color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>After listening to Stoyan talk perf, he wondered if there was an issue with the <code>image.data</code> access, and changed the code to:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-26');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-26">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">canvas = document.<span style="color: #006600;">getElementById</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"canvas"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">context = canvas.<span style="color: #006600;">getContext</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"2d"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">image = context.<span style="color: #006600;">getImageData</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;">0</span>, <span style="color:#800000;">0</span>, SCREEN_WIDTH, SCREEN_HEIGHT<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> pixels = SCREEN_WIDTH*SCREEN_HEIGHT;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> imageData = image.<span style="color: #006600;">data</span>; <span style="color: #009900; font-style: italic;">// here we detach the pixels array from DOM</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000066; font-weight: bold;">while</span><span style="color:#006600; font-weight:bold;">&#40;</span>--pixels<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;imageData<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;">4</span>*i+<span style="color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span> = r; <span style="color: #009900; font-style: italic;">// Red value</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;imageData<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;">4</span>*i+<span style="color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span> = g; <span style="color: #009900; font-style: italic;">// Green value</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;imageData<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;">4</span>*i+<span style="color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#93;</span> = b; <span style="color: #009900; font-style: italic;">// Blue value</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;imageData<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;">4</span>*i+<span style="color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#93;</span> = a; <span style="color: #009900; font-style: italic;">// Alpha value</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">image.<span style="color: #006600;">data</span> = imageData; <span style="color: #009900; font-style: italic;">// And here we attache it back </span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">context.<span style="color: #006600;">putImageData</span><span style="color:#006600; font-weight:bold;">&#40;</span>image, <span style="color:#800000;">0</span>, <span style="color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>He wrapped this all up in a benchmark that showed the perf diff. It actually really seemed to matter when using closures for namespaces:</p>
<p><img src="http://www.onaluf.org/media/canvas_benchmark.png"/></p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/canvas-image-data-optimization-tip/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>iPad JavaScript Shockingly Slow?</title>
		<link>http://ajaxian.com/archives/ipad-javascript-shockingly-slow</link>
		<comments>http://ajaxian.com/archives/ipad-javascript-shockingly-slow#comments</comments>
		<pubDate>Thu, 06 May 2010 11:00:04 +0000</pubDate>
		<dc:creator>Ben Galbraith</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Section]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=9208</guid>
		<description><![CDATA[Douglas "My Guns Are Bigger Than Yours" Crockford sent us a pointer to Moonwatcher's post on entitled "My MacBook Pro runs JavaScript 26.7x as fast as my iPad". After Moonwatcher ran SunSpider on the iPad, he concluded: It's one thing not to be able to run Flash apps. But JavaScript performance like this effectively means <a href="http://ajaxian.com/archives/ipad-javascript-shockingly-slow">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p>Douglas "<a href="http://crockfordfacts.com/">My Guns Are Bigger Than Yours</a>" Crockford sent us a pointer to Moonwatcher's post on entitled "<a href="http://www.globelogger.com/2010/04/my-macbook-pro-runs-javascript-267x-as-fast-as-my-ipad.html">My MacBook Pro runs JavaScript 26.7x as fast as my iPad</a>".</p>
<p><a href="http://www.globelogger.com/2010/04/my-macbook-pro-runs-javascript-267x-as-fast-as-my-ipad.html"><img src="http://ajaxian.com/wp-content/images/ipadgraph.png" alt="" title="iPad Performance Graph" width="434" height="346" class="alignnone size-full wp-image-9210" /></a></p>
<p>After Moonwatcher ran SunSpider on the iPad, he concluded:</p>
<blockquote><p>
It's one thing not to be able to run Flash apps. But JavaScript performance like this effectively means the iPad can't run complex JavaScript apps either. Interesting.
</p></blockquote>
<p>Many folks in the comments are quick to retort that:</p>
<blockquote><p>
And have you noticed this to be an actual problem, in practice, or are you just obsessing over benchmarks?
</p></blockquote>
<p>and:</p>
<blockquote><p> Heavy ajax sites like gmail run quite well on the iPad. Yes, I have an iPad and use it for such sites everyday (including for writing this post).</p></blockquote>
<p>But it got me curious: what have you noticed about the iPad's performance and your web apps? Does it inhibit the types of experiences you're trying to create?</p>
<p>In my own experience, mobile devices have shown us that JavaScript-driven animations are generally a bad idea when you want multiple sprites or extreme performance, but CSS animations are there to fill the gap. Otherwise, JS perf. on mobile is generally fine for what I've tried to do.</p>
<p>I also find it interesting that while the iPad is slower than my MacBook Pro, I rarely notice it--and I certainly haven't noticed anything as dramatic as an alleged 27x gap. Have you?</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/ipad-javascript-shockingly-slow/feed</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>Page Speed SDK released; HAR to Page Speed tool created</title>
		<link>http://ajaxian.com/archives/page-speed-sdk-released-har-to-page-speed-tool-created</link>
		<comments>http://ajaxian.com/archives/page-speed-sdk-released-har-to-page-speed-tool-created#comments</comments>
		<pubDate>Mon, 03 May 2010 11:55:39 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=9191</guid>
		<description><![CDATA[Releasing the Page Speed SDK (all open source) is one step closer to having a common performance metric across all web development tools and environments. Imagine being able to get the same performance analysis results from Firebug, Web Inspector, HttpWatch, Fiddler, Keynote, and Gomez. This will help us develop a common vocabulary and bring more <a href="http://ajaxian.com/archives/page-speed-sdk-released-har-to-page-speed-tool-created">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<blockquote><p>
Releasing the Page Speed SDK (all open source) is one step closer to having a common performance metric across all web development tools and environments. Imagine being able to get the same performance analysis results from Firebug, Web Inspector, HttpWatch, Fiddler, Keynote, and Gomez. This will help us develop a common vocabulary and bring more consistency and quality to the field of web performance optimization.
</p></blockquote>
<p>This is a quote from Steve on the new <a href="http://www.stevesouders.com/blog/2010/05/01/har-to-page-speed/">HAR to Page Speed</a> work that he has built on top of other work:</p>
<blockquote><p>
The importance of an industry standard <a href="http://groups.google.com/group/firebug-working-group/web/http-tracing---export-format">HTTP archive format</a> is huge. Adoption of HAR allows companies and data gathering institutions (such as the Internet Archive) to record the web page experience and pull it up later for further review. It provides a way to exchange information across tools. And it provides an open standard for sharing web loading information between individuals – developer to developer as well as customer to customer support.</p>
<p>In their last few releases the <a href="http://code.google.com/speed/page-speed/">Page Speed</a> team has mentioned porting their performance analysis logic from JavaScript to C++. The resulting library is called “native library” – not too jazzy. But last week they released the <a href="http://code.google.com/p/page-speed/wiki/DownloadPageSpeed?tm=2">Page Speed SDK</a>. The documentation is slim, but I noticed a command-line tool called <code>har_to_pagespeed</code>.</p>
<p>I downloaded the SDK. It built fine on my Dreamhost shared server. Then I wrapped it with a file upload PHP page and created <a href="http://stevesouders.com/flint/">HAR to Page Speed</a>.
</p></blockquote>
<p>Once you upload a HAR file you get page speed info and more:</p>
<p><a href="http://ajaxian.com/wp-content/images/har-pagespeed.png"><img src="http://ajaxian.com/wp-content/images/har-pagespeed.png" alt="" title="har-pagespeed" width="348" height="363" class="alignnone size-full wp-image-9192" /></a></p>
<p>For a full example, check out <a href="http://stevesouders.com/flint/index.php?f=cnn.har">a CNN.com archive</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/page-speed-sdk-released-har-to-page-speed-tool-created/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Best of Steve: Performance at JSConf</title>
		<link>http://ajaxian.com/archives/the-best-of-steve-performance-at-jsconf</link>
		<comments>http://ajaxian.com/archives/the-best-of-steve-performance-at-jsconf#comments</comments>
		<pubDate>Sun, 18 Apr 2010 19:54:18 +0000</pubDate>
		<dc:creator>Michael Mahemoff</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Presentation]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=9047</guid>
		<description><![CDATA[(Live blogging notes.) At JSConf, Steve Souders walks us through several performance-optimising things on his mind lately. Site Speed in PageRank A week ago, Google announced site speed is going to be taken into account for PageRank. For Steve, this is a dream come true. Now companies are going to start investing in performance, so <a href="http://ajaxian.com/archives/the-best-of-steve-performance-at-jsconf">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p><img src="http://ajaxian.com/wp-content/images/steve_book_large.jpg" alt="steve_book_large" title="steve_book_large" width="140" height="185" class="alignnone size-full wp-image-9046" /></p>
<p>(Live blogging notes.)</p>
<p>At JSConf, <a href="http://stevesouders.com/">Steve Souders</a> walks us through several performance-optimising things on his mind lately.</p>
<h3>Site Speed in PageRank</h3>
<p>A week ago, Google announced site speed is going to be taken into account for PageRank. For Steve, this is a dream come true. Now companies are going to start investing in performance, so less of those slow-loading sites that frustrated him enough to get started down this performance path. One of the criticisms is that this will favour big companies, but Steve points out that smaller companies are often more nimble and able to adapt to changes like this.</p>
<p>As part of Google's webmaster tools, site performance is shown to respective site masters, along with some guidance. Another good resource is <a href="http://www.webpagetest.org/">http://www.webpagetest.org/</a>. Other than its main measurement service, a great feature of WebPageTest is side-by-side comparisons. Show your manager a side-by-side against a competitor for guaranteed satisfaction.</p>
<h3>Performance of Third Party Widgets</h3>
<p>There's been something of a reversal in performance hotspots. Five years ago, it was the core application code that was mostly slowing things down, much as teams would like to blame performance problem on 3rd party ads. Nowadays, those apps have been more finely tuned, and at the same time, people are using more 3rd party stuff - not just ads, but embedded widgets. All of which explains why Steve's been looking at third-party widgets lately. You can see what he's been up to at <a href="http://www.stevesouders.com/p3pc/">P3PC</a>, a benchmark tool for third-party widgets.</p>
<p>A key question is how are the widgets embedded? People are no longer just doing the blocking document.write calls. Instead, it's much more common to dynamically create a script tag and append to the page.  But where and how do you append it? jQuery's library code, for example, does it in a simple, elegant, manner:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-28');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-28">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> head = document.<span style="color: #006600;">getElementsByTagName</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"head"</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span> || document.<span style="color: #006600;">documentElement</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; script = document.<span style="color: #006600;">createElement</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"script"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">...</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #006600;">head</span>.<span style="color: #006600;">insertBefore</span><span style="color:#006600; font-weight:bold;">&#40;</span>script, head.<span style="color: #006600;">firstChild</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>Others, not so much. See Steve's recent blog posts for more analysis on these techniques (<a href="http://www.stevesouders.com/blog/2010/03/03/p3pc-google-analytics/">e.g. on Google Analytics</a>).</p>
<h3>Frag Tag</h3>
<p>An <a href="http://www.stevesouders.com/blog/2010/02/15/browser-performance-wishlist/#download_scripts">early proposal</a> from Steve and Alex Russell ...</p>
<pre>
&lt;FRAG&gt;
&lt;script src="snippet.js"&gt;&lt;/script&gt;
&lt;/FRAG&gt;
</pre>
<p>The idea is that the frag loads independently; even document.write doesn't block. And it could go further, into a sandboxing mechanism. "If we had this frag tag, it would be one of the biggest things website owners could do to improve the performance of their pages."</p>
<h3>Browser Disk Cache</h3>
<p>The main message here is that browser disk cache is too small, and he's been talking to vendors about upping capacity. <a href="http://stevesouders.com/cache.php">And there's a survey for you</a>.</p>
<h3>What makes sites feel slow?</h3>
<p>So lately Steve's been going back to basics and looking at user perception, thinking not just about how fast the Javascript takes to load, but how fast till the user sees anything. So he's promoting the standard progressive enhancement pattern, similar to <a href="http://ajaxian.com/archives/facebook-javascript-jsconf">Facebook's earlier talk</a>:</p>
<p>* Deliver HTML<br />
* Defer JS<br />
* Avoid DOM<br />
* Decorate later.</p>
<p>He's done a couple of studies to this end:</p>
<p>* Charting page load time - as the user actually sees it - against market share...in an attempt to show faster sites mean bigger market share.<br />
* Looking at initiail payload versus execution. Many of the sample (highly popular) sites are serving many functions on initial payload, which could be deferred until later - putting scripts at the bottom of the page, and loading scripts asynchronously.</p>
<h3>Other Stuff</h3>
<p>Check out:</p>
<p>* <a href="http://www.browserscope.org/">Browserscope</a>, "a community-driven project for profiling web browsers".</p>
<p>* HTTP Archive Format (HAR). An industry standard for capturing Used in an increasing number of tools, e.g. NetExport plugin in Firebug.</p>
<p>* <a href="http://en.oreilly.com/velocity2010">Velocity Conference</a>, which Steve founded with O'Reilly. June 22-24, Santa Clara.</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/the-best-of-steve-performance-at-jsconf/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Facebook&#8217;s Javascript Speed-Up</title>
		<link>http://ajaxian.com/archives/facebook-javascript-jsconf</link>
		<comments>http://ajaxian.com/archives/facebook-javascript-jsconf#comments</comments>
		<pubDate>Sun, 18 Apr 2010 15:56:58 +0000</pubDate>
		<dc:creator>Michael Mahemoff</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Showcase]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=9023</guid>
		<description><![CDATA[(Live blogging notes.) Makinde Adeagbo is describing Facebook's Javascript performance optimisation efforts at JSConf. By 2009, it became clear something had to be done, as the trend was towards longer and longer page loads. Back in 2006, the objective had been super fast page loading: "If any page loads in under 100ms, it takes way <a href="http://ajaxian.com/archives/facebook-javascript-jsconf">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p><img src="http://ajaxian.com/wp-content/images/facebook_logo1.jpg" alt="facebook_logo" title="facebook_logo" width="150" height="56" class="alignnone size-full wp-image-9022" /></p>
<p>(Live blogging notes.)</p>
<p>Makinde Adeagbo is describing Facebook's Javascript performance optimisation efforts at JSConf. By 2009, it became clear something had to be done, as the trend was towards longer and longer page loads. Back in 2006, the objective had been super fast page loading: "If any page loads in under 100ms, it takes way too long". By 2008, given all the new interactive features on the page, the 100 millisecond target had expanded to 1 second, and by mid-2009, pages were taking 5 seconds to load. Even HipHop, the PHP compiler, was smaller than the Javascript code base. And when Steve Souders called out Facebook in his book numerous times, it only adding to the team's sense of fun and joy ;).</p>
<p>In June 2009, the team quickly chose a target by year's end by simply checking the load time without Javascript: 2.5 seconds. Thus, dropping load time from 5 seconds to 2.5 seconds was the goal for end of 2009.</p>
<p>The first initiative was to include the Javascript at the bottom of the page. Great, it's faster, but at what cost? A big one: Users try to click on controls, and nothing happens. Back to the drawing board, and the team refined the setup so that the actionable stuff was initialised on the top of the page. But how to minimise all this code at the top of the page?  Here, the team exploited the observation that most controls work the same way:</p>
<p>* User clicks<br />
* Sends ASync request<br />
* Insert/Replace some content</p>
<p>So the team set up elements like this:</p>
<p>&lt;a href="/ring.php rel="dialog"&gt;...&lt;/a&gt;</p>
<p>... And then <a href="http://www.domscripting.com/blog/display/41">hijacked</a> them with a standard listener routine, one that would work for most of the controls. (Most, not all; 80/20 principle is in effect here.) This way, they could have one small listener routine to handle most of the controls on the page. Once the user clicks, the server gets called and outputs a new snippet of Javascript:</p>
<p>The Javascript:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-32');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-32">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">new</span> Dialog<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #006600;">setTitle</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #006600;">setBody</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #006600;">show</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>would be output by a PHP script, and then evaluated in the browser:</p>
<div class="igBar"><a href="javascript:showCodeTxt('php-33');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">PHP:</span>
<div id="php-33">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$response</span> = <span style="color:#000000; font-weight:bold;">new</span> DialogResponse<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$response</span>-&gt;<span style="color:#006600;">setTitle</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>-&gt;<span style="color:#006600;">setBody</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>-&gt;<span style="color:#006600;">send</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>(A form of On-Demand Javascript.)</p>
<p>In fact, the team has a whole PHP library for outputting Javascript. For example, when a request comes in to expand a new story:</p>
<div class="igBar"><a href="javascript:showCodeTxt('php-34');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">PHP:</span>
<div id="php-34">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$response</span> = <span style="color:#000000; font-weight:bold;">new</span> AsyncResponse<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$response</span>-&gt;<span style="color:#006600;">setContent</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"#elem_id"</span>, <span style="color:#0000FF;">$new_content</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$response</span>-&gt;<span style="color:#006600;">appendContent</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"#content .stories"</span>, <span style="color:#0000FF;">$new_story</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$response</span>-&gt;<span style="color:#006600;">send</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>And they are using a convention: "ajaxify=1" on an element indicates it's ... Ajaxified.</p>
<p>At this point, the team had now Ajaxified a bunch of features, but people were still skeptical about more complicated features. For example, would setting status be too hard with the same techniques. So after some research, Makinde came back with an epiphany: the humble form. Whereas the previous async requests were effectively information-less - just a simple directive and maybe an ID - the requests would now include content too. And of course, most of these things look nothing like forms due to styling. But underneath, they're still forms, e.g. the entire comments block is a single form.</p>
<p>Nowadays, most of Facebook runs without complete page refreshes, by dynamically flipping the content and the fragment ID. (What Facebook calls page transitions.)</p>
<p>Ongoing, Makinde says performance optimisation requires ongoing vigilance. Every engineer has their special case, but in the scheme of things, it's better to say no to new features unless they can be strongly justified. For example, we can live with user submitting a form that hasn't yet been hijacked; a complete page refresh is fine on occasion. We don't like it, but we don't want to make it a special case just for the sake of it.</p>
<p>The Gantt charts tell a great tale: users now see content much earlier, and it's interactive. So how did they fare with that 2.5 second goal for year's end? Achieved by December 23. And Makinde wants people to know Facebook is hiring as they have more Javascript to write...and delete.</p>
<p>UPDATE: And here are the slides ...</p>
<div style="width:425px" id="__ss_3769022"><strong style="display:block;margin:12px 0 4px"><a href="http://www.slideshare.net/makinde/javascript-primer" title="Javascript Primer">Javascript Primer</a></strong><object width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=jsconfprimertalk-100418161633-phpapp02&#038;stripped_title=javascript-primer" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=jsconfprimertalk-100418161633-phpapp02&#038;stripped_title=javascript-primer" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object>
<div style="padding:5px 0 12px">View more <a href="http://www.slideshare.net/">presentations</a> from <a href="http://www.slideshare.net/makinde">makinde</a>.</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/facebook-javascript-jsconf/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Mozilla Web Caching Summit</title>
		<link>http://ajaxian.com/archives/mozilla-web-caching-summit</link>
		<comments>http://ajaxian.com/archives/mozilla-web-caching-summit#comments</comments>
		<pubDate>Wed, 07 Apr 2010 15:39:34 +0000</pubDate>
		<dc:creator>Ben Galbraith</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=8869</guid>
		<description><![CDATA[As part of their on-going efforts to engage directly with the web developer community, Mozilla hosted a Web Caching Summit earlier this week to discuss how the web platform could better meet the needs of developers. In attendance were developers who work on Facebook, Google Search, Microsoft Office Live, Twitter, Yahoo, SproutCore, and Palm webOS. <a href="http://ajaxian.com/archives/mozilla-web-caching-summit">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p><img src="http://ajaxian.com/wp-content/images/moz.png" alt="moz" title="moz" width="300" height="214" class="alignnone size-full wp-image-8871" /></p>
<p>As part of their on-going efforts to engage directly with the web developer community, Mozilla hosted a Web Caching Summit earlier this week to discuss how the web platform could better meet the needs of developers. In attendance were developers who work on Facebook, Google Search, Microsoft Office Live, Twitter, Yahoo, SproutCore, and Palm webOS. <a href="http://arunranga.com/blog/">Arun Ranganathan</a> moderated the gathering.</p>
<p>One of the core challenges identified by the group was that frequent visitors of a site are often missing resources in their browser cache that the site authors think should be there. In other words, why is the same user requesting a static cacheable image with a year-long expiration every few days?</p>
<p>A lively discussion ensued over 5 hours talking about this problem and others, touching on why this is the case and what page developers could do to maximize the cache-ablity of their websites.</p>
<p>A high-level summary of the outcome is:</p>
<p>- browsers should immediately investigate increasing the size of the browser cache<br />
- Mozilla will learn more about caching behaviors in the browser, perhaps by using Test Pilot to collect more information from end users<br />
- Mozilla will investigate means of prioritizing content in the cache, either by allowing developers to prioritize content (i.e., set some content on the page as a higher cache priority than others) or through implicitly prioritizing (e.g., CSS and JS above images).</p>
<p>What do you think browser vendors could do to improve caching?</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/mozilla-web-caching-summit/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>RequireJS: Asynchronous JavaScript loading</title>
		<link>http://ajaxian.com/archives/requirejs-asynchronous-javascript-loading</link>
		<comments>http://ajaxian.com/archives/requirejs-asynchronous-javascript-loading#comments</comments>
		<pubDate>Thu, 18 Mar 2010 11:15:12 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Node]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=8730</guid>
		<description><![CDATA[A certain someone was talking to me about how they find it interesting that node.js, the JavaScript server framework du jour which loves all things async, starts life with a bunch of synchronous require() calls. Now, this is actually quite fine since the startup of the server is not the issue at hand. However, if <a href="http://ajaxian.com/archives/requirejs-asynchronous-javascript-loading">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p>A certain someone was talking to me about how they find it interesting that node.js, the JavaScript server framework du jour which loves all things async, starts life with a bunch of synchronous <code>require()</code> calls. Now, this is actually quite fine since the startup of the server is not the issue at hand.</p>
<p>However, if you are running <code>require()</code>-esque loader code in the browser you want to avoid blocking calls else Steve Souders will come over and beat you up.</p>
<p>I have seen a couple of interesting items in this area:</p>
<p><b>RequireJS</b></p>
<p>James Burke of Mozilla Messaging has spent a lot of time in the depths of <code>dojo.require()</code>. He has taken another look at the problem and <a href="http://requirejs.org/">RequireJS</a> a solution that offers:</p>
<ul>
<li>some sort of #include/import/require</li>
<li>ability to load nested dependencies</li>
<li>ease of use for developer but then backed by an optimization tool that helps deployment
</li>
</ul>
<p>He <a href="http://requirejs.org/docs/why.html">walks through the problem</a> and why other solutions like LABjs, CommonJS require, and Dojo itself don't cover all of his bases.</p>
<p>The end result is:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-36');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-36">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">// code that runs asynchronously when the library is loaded</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">require<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color: #3366CC;">"some/script.js"</span><span style="color:#006600; font-weight:bold;">&#93;</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//This function is called after some/script.js has loaded.</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">// defining the module and dependencies</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">require.<span style="color: #006600;">def</span><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// The name of this module</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #3366CC;">"types/Manager"</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// The array of dependencies</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color: #3366CC;">"types/Employee"</span><span style="color:#006600; font-weight:bold;">&#93;</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// The function to execute when all dependencies have loaded. The arguments</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// to this function are the array of dependencies mentioned above.</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">function</span> <span style="color:#006600; font-weight:bold;">&#40;</span>Employee<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">function</span> Manager <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">reports</span> = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// This will now work</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Manager.<span style="color: #006600;">prototype</span> = <span style="color: #003366; font-weight: bold;">new</span> Employee<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// return the Manager constructor function so it can be used by other modules.</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> Manager;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p><b>Google Analytics "async add to []" Pattern</b></p>
<p>When talking to Davis Frank of Pivotal about some Google Analytics code, he pointed me to <a href="http://code.google.com/apis/analytics/docs/tracking/asyncTracking.html">details about the new GA asynchronous loader</a> that we very <a href="/archives/google-analytics-unblocks-the-web-w-async-support">excitedly blogged about</a> since GA was such a blocking offender on the Web.</p>
<p>Part of the asynchronous API is that you, the developer create an array, and use the <code>push()</code> method to put commands on a queue. This means that you can start pushing commands immediately.</p>
<p>Then, when the GA code loads asynchronously, it takes over that array and wraps those standard methods. Now it can take the commands and fire them back to GA and <code>push()</code> can do more. Freaking brilliant.</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/requirejs-asynchronous-javascript-loading/feed</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
	</channel>
</rss>

