<?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>Thu, 18 Mar 2010 20:22:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<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[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 you [...]]]></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-2');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-2">
<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>15</slash:comments>
		</item>
		<item>
		<title>HTML Minification</title>
		<link>http://ajaxian.com/archives/html-minification</link>
		<comments>http://ajaxian.com/archives/html-minification#comments</comments>
		<pubDate>Wed, 10 Mar 2010 11:14:51 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=8697</guid>
		<description><![CDATA[Good old Kangax has been playing with HTML minification and has shared his new tool in an early stage.

What does it do?
Kangax has forked John Resig's HTML parser which parses the HTML and sends that into the Minifier. This has rules that do things like whitespace optimization, comment removal, and collapsing boolean attributes (e.g. disabled="true" [...]]]></description>
			<content:encoded><![CDATA[<p>Good old Kangax has been <a href="http://perfectionkills.com/experimenting-with-html-minifier/">playing with HTML minification</a> and has shared <a href="http://kangax.github.com/html-minifier/">his new tool</a> in an early stage.</p>
<p><img src="http://perfectionkills.com/images/minifier-screenshot.png" width="480"/></p>
<p><b>What does it do?</b></p>
<p>Kangax has <a href="http://github.com/kangax/html-minifier/blob/gh-pages/src/htmlparser.js">forked John Resig's HTML parser</a> which parses the HTML and sends that into the Minifier. This has rules that do things like whitespace optimization, comment removal, and collapsing boolean attributes (e.g. disabled="true" -> disabled).</p>
<p>He also has a linter going:</p>
<blockquote><p>
While working on minifier, I realized that oftentimes the most wasteful part of the markup is not white space, comments or boolean attributes, but inline styles, scripts, presentational or deprecated elements and attributes. None of these can be simply stripped, as that could affect state of the document and is just too obtrusive. What can be done, however, is reporting of these occurences to the user. HTMLLint is even a smaller script, whose job is exactly that—to log any deprecated or presentational elements/attributes encountered during parsing. Additionally, it detects event attributes (e.g. onclick, onmouseover, etc.). The rationale for this is that moving contents of event attributes to external script allows to <a href="http://perfectionkills.com/optimizing-html/#3_onclick_onmouseover_etc">take advantage of resource caching</a>.
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/html-minification/feed</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Firefox gets hardware acceleration in early stage</title>
		<link>http://ajaxian.com/archives/firefox-gets-hardware-acceleration-in-early-stage</link>
		<comments>http://ajaxian.com/archives/firefox-gets-hardware-acceleration-in-early-stage#comments</comments>
		<pubDate>Fri, 05 Mar 2010 11:25:43 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=8683</guid>
		<description><![CDATA[Bass Schouten is a cool name, and the Mozillan has presented Direct2D hardware acceleration.
You have to grab Firefox nightly, do the about:config / gfx.font_rendering.directwrite.enabled game, but then you get to see it in action.
IE9 showed off how they will support hardware rendering, and I am sure we will see more at MIX, but it is [...]]]></description>
			<content:encoded><![CDATA[<p>Bass Schouten is a cool name, and the Mozillan has <a href="http://www.basschouten.com/blog1.php/2010/03/02/presenting-direct2d-hardware-acceleratio">presented Direct2D hardware acceleration</a>.</p>
<p>You have to grab Firefox nightly, do the <code>about:config</code> / <code>gfx.font_rendering.directwrite.enabled</code> game, but then you get to see it in action.</p>
<p>IE9 showed off <a href="http://ajaxian.com/archives/ie-9-hardware-rendering-new-js-engine-css-standards-and-more">how they will support hardware rendering</a>, and I am sure we will see more at MIX, but it is very cool to see this across the board.</p>
<p>CSS Transforms/Transitions/Animations are going to feel like butter in 2010!</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/firefox-gets-hardware-acceleration-in-early-stage/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>New performance case studies&#8230; starting with the Digg widget</title>
		<link>http://ajaxian.com/archives/new-performance-case-studies-starting-with-the-digg-widget</link>
		<comments>http://ajaxian.com/archives/new-performance-case-studies-starting-with-the-digg-widget#comments</comments>
		<pubDate>Mon, 01 Mar 2010 11:53:06 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=8666</guid>
		<description><![CDATA[Would we all like Steve to sit down with us on our project and do a performance case study? Well, we may not get that, but we are getting to at least sit in on others.
Steve has kicked off his long awaited series that runs performance case studies on third party content. I have been [...]]]></description>
			<content:encoded><![CDATA[<p>Would we all like Steve to sit down with us on our project and do a performance case study? Well, we may not get that, but we are getting to at least sit in on others.</p>
<p>Steve has kicked off his long awaited <a href="http://www.stevesouders.com/p3pc/">series that runs performance case studies on third party content</a>. I have been talking to Steve about this for a couple of years, so it is great to see it. It is a sensitive topic as you never want to show up a team when you are just trying to help and educate.</p>
<p>First on the block? The <a href="http://www.stevesouders.com/blog/2010/02/28/p3pc-digg-widget-3/">Digg widget</a>.</p>
<p><img src="http://ajaxian.com/wp-content/images/diggwidgetstats.png" alt="diggwidgetstats" title="diggwidgetstats" width="470" height="59" class="alignnone size-full wp-image-8667"/></p>
<p>Steve goes into detail and finds a lot of short comings. You could probably guess some of the bad actors. Mr. document.write() appears for example. We get the problems, and proposed solutions to the issue. Steve also tries to note what a user of third party content can do regardless of if the third party guys fix their issues (put in iframe!).</p>
<blockquote><p>
Here are the most important performance issues along with recommended solutions.</p>
<ol>
<li> 9 HTTP requests, 52 kB transferred over the wire, and 107 kB of JavaScript (uncompressed) is a lot of content for a single widget.
<p><strong>Recommendations:</strong></p>
<ul>
<li> Concatenate these three scripts: JS_Libraries, widgetjsvars, and omnidiggthis. (eliminates 2 HTTP requests)
</li>
<li> Run <a href="http://code.google.com/speed/page-speed/">Page Speed’s</a> “Defer loading JavaScript” feature and see how much of the JavaScript is not used. If it’s sizable, delete it. (This feature is currently broken in the latest version of Page Speed, but a fix is imminent.) (eliminates ?? kB)</li>
<li> Optimize the images – widget-logo.png and get-widget.png can both be reduced by ~3 kB. (eliminates ~6 kB)
</li>
<li> Sprite widget-logo.png and shade-com.png. (eliminates 1 HTTP request) </li>
</ul>
</li>
<li>The widget’s scripts block the main page’s content from downloading.  Looking at the waterfall chart, the main page includes the image “digg-waterfall.png” (row 10).  Notice how this image doesn’t start downloading until after all the scripts for the Digg widget are received.<br />
<strong>Recommendations:</strong></p>
<ul>
<li> Instead of loading the scripts using document.write, load them <a href="http://www.stevesouders.com/blog/2009/04/27/loading-scripts-without-blocking/">without blocking other downloads</a>. The scripts are already suffering from race condition behavior, as evidenced by this comment from widgetjsvars:<br />
<table style="margin-top: 4px;" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="font-family: monospace; text-align: right; background: none repeat scroll 0% 0% rgb(238, 238, 238); border-right: 1px solid; padding: 2px 4px 2px 8px; vertical-align: top;">1:</td>
<td style="font-family: monospace; text-align: left; background: none repeat scroll 0% 0% rgb(238, 238, 238); padding: 2px 8px;">if (!digg || !digg.$) setTimeout(function() { diggwb(obj); }, 200); //hack for IE not loading scripts that are included via document.write until it decides too</td>
</tr>
</tbody>
</table>
</li>
</ul>
<p>So it probably isn’t too much work to avoid race conditions when making all the scripts load asynchronously.
</li>
<li>The widget’s stylesheet blocks the main page from rendering in IE.
<p><strong>Recommendations:</strong></p>
<ul>
<li> Instead of loading the stylesheet using document.write, load it via JavaScript as described in <a href="http://www.stevesouders.com/blog/2010/02/12/5d-dynamic-stylesheets/">5d dynamic stylesheets</a>. </li>
</ul>
</li>
<li style="margin-top: 8px;"> Four of the resources aren’t cached long enough.<br />
<strong>Recommendations:</strong></p>
<ul>
<li> Two scripts aren’t cacheable because they have an expiration date in the past. widgetjs is part of the snippet, so it can’t have a long expiration date, but something like an hour or a day would be better than a date in the past. widgetjsvars could have a far future expiration date since its URL is specified in widgetjs.
</li>
<li> The three images are only cacheable for a day. They should have a far future expires header since the image filename can be change if it’s modified. </li>
</ul>
</li>
<li>There are approximately 30 inefficient CSS selectors. Because this stylesheet is part of the main page, the selectors will cause the overall page to render more slowly when these selectors are applied to the elements in the main page.<br />
<strong>Recommendations:</strong></p>
<ul>
<li> Reduce the performance impact by <a href="http://www.stevesouders.com/blog/2009/06/18/simplifying-css-selectors/">simplifying these CSS selectors</a>. </li>
</ul>
</li>
<li>Four of the resources have ETags which <a href="http://developer.yahoo.net/blog/archives/2007/07/high_performanc_11.html">reduces their cacheability</a>.
<p><strong>Recommendations:</strong></p>
<ul>
<li> Configure the ETags for widget.css, widget-logo.png, get-widget.png, and shade-com.png. </li>
</ul>
</li>
</ol>
</blockquote>
<p>This is just the first example. What else would you like to see Steve tackle?</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/new-performance-case-studies-starting-with-the-digg-widget/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Mozilla JägerMonkey: Method based JIT + Trace based JIT = speed</title>
		<link>http://ajaxian.com/archives/mozilla-jagermonkey-method-based-jit-trace-based-jit-speed</link>
		<comments>http://ajaxian.com/archives/mozilla-jagermonkey-method-based-jit-trace-based-jit-speed#comments</comments>
		<pubDate>Sat, 27 Feb 2010 05:05:58 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=8661</guid>
		<description><![CDATA[
David Anderson: "TraceMonkey has rocket boosters, so it runs really fast when the boosters are on, but the boosters can’t always be turned on."

Opera's new JIT compiler Carakan is doing well as we just posted. What is Mozilla doing with TraceMonkey? A lot.
Mozilla JägerMonkey adds method based JIT (of V8 and Nitro fame) to keep [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>
David Anderson: "TraceMonkey has rocket boosters, so it runs really fast when the boosters are on, but the boosters can’t always be turned on."
</p></blockquote>
<p>Opera's new JIT compiler Carakan is <a href="http://ajaxian.com/archives/opera-10-50">doing well as we just posted</a>. What is Mozilla doing with TraceMonkey? A lot.</p>
<p><a href="https://wiki.mozilla.org/JaegerMonkey">Mozilla JägerMonkey</a> adds method based JIT (of V8 and Nitro fame) to keep the boosters on.</p>
<p>We learn more from <a href="http://blog.mozilla.com/dmandelin/2010/02/26/starting-jagermonkey/">David Mandelin</a> and <a href="http://www.bailopan.net/blog/?p=683">David Anderson</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/mozilla-jagermonkey-method-based-jit-trace-based-jit-speed/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Steve&#8217;s Browser Performance Wishlist</title>
		<link>http://ajaxian.com/archives/steves-browser-performance-wishlist</link>
		<comments>http://ajaxian.com/archives/steves-browser-performance-wishlist#comments</comments>
		<pubDate>Mon, 22 Feb 2010 11:12:05 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=8635</guid>
		<description><![CDATA[Steve Souders has put together a browser performance wishlist that answers the question "What are the most important changes browsers could make to improve performance?"

download  scripts without blocking
SCRIPT  attributes
resource  packages
border-radius
cache  redirects
link  prefetch
Web  Timing spec
remote  JS debugging
Web  Sockets
History
anchor  ping
progressive  XHR
stylesheet  &#38; inline JS
SCRIPT  DEFER [...]]]></description>
			<content:encoded><![CDATA[<p>Steve Souders has put together a <a href="http://www.stevesouders.com/blog/2010/02/15/browser-performance-wishlist/">browser performance wishlist</a> that answers the question "What are the most important changes browsers could make to improve performance?"</p>
<ul>
<li><a href="http://www.stevesouders.com/blog/2010/02/15/browser-performance-wishlist/#download_scripts">download  scripts without blocking</a></li>
<li><a href="http://www.stevesouders.com/blog/2010/02/15/browser-performance-wishlist/#script_attributes">SCRIPT  attributes</a></li>
<li><a href="http://www.stevesouders.com/blog/2010/02/15/browser-performance-wishlist/#resource_packages">resource  packages</a></li>
<li><a href="http://www.stevesouders.com/blog/2010/02/15/browser-performance-wishlist/#border_radios">border-radius</a></li>
<li><a href="http://www.stevesouders.com/blog/2010/02/15/browser-performance-wishlist/#cache_redirects">cache  redirects</a></li>
<li><a href="http://www.stevesouders.com/blog/2010/02/15/browser-performance-wishlist/#link_prefetch">link  prefetch</a></li>
<li><a href="http://www.stevesouders.com/blog/2010/02/15/browser-performance-wishlist/#web_timing">Web  Timing spec</a></li>
<li><a href="http://www.stevesouders.com/blog/2010/02/15/browser-performance-wishlist/#remote_js">remote  JS debugging</a></li>
<li><a href="http://www.stevesouders.com/blog/2010/02/15/browser-performance-wishlist/#web_sockets">Web  Sockets</a></li>
<li><a href="http://www.stevesouders.com/blog/2010/02/15/browser-performance-wishlist/#history">History</a></li>
<li><a href="http://www.stevesouders.com/blog/2010/02/15/browser-performance-wishlist/#anchor_ping">anchor  ping</a></li>
<li><a href="http://www.stevesouders.com/blog/2010/02/15/browser-performance-wishlist/#progressive_xhr">progressive  XHR</a></li>
<li><a href="http://www.stevesouders.com/blog/2010/02/15/browser-performance-wishlist/#stylesheet_js">stylesheet  &amp; inline JS</a></li>
<li><a href="http://www.stevesouders.com/blog/2010/02/15/browser-performance-wishlist/#script_defer">SCRIPT  DEFER for inline scripts</a></li>
<li><a href="http://www.stevesouders.com/blog/2010/02/15/browser-performance-wishlist/#import_improvements">@import  improvements</a></li>
<li><a href="http://www.stevesouders.com/blog/2010/02/15/browser-performance-wishlist/#font_face">@font-face  improvements</a></li>
<li><a href="http://www.stevesouders.com/blog/2010/02/15/browser-performance-wishlist/#stylesheets_iframes">stylesheets  &amp; iframes</a></li>
<li><a href="http://www.stevesouders.com/blog/2010/02/15/browser-performance-wishlist/#paint_events">paint  events</a></li>
<li><a href="http://www.stevesouders.com/blog/2010/02/15/browser-performance-wishlist/#missing_schema">missing  schema, double downloads</a></li>
</ul>
<p>He also notes a couple of new ideas that he is very much behind:</p>
<blockquote><p>
<b>SPDY</b></p>
<p>SPDY is a <a href="http://blog.chromium.org/2009/11/2x-faster-web.html">proposal from  Google</a> for making three major improvements to HTTP: compressed  headers, multiplexed requests, and prioritized responses. Initial studies showed 25 top sites were loaded 55% faster. Server and client implementations are available, and some other  organizations and individuals have completed server and client  implementations. The <a href="http://dev.chromium.org/spdy/spdy-protocol">protocol</a> draft has been published for review. </p>
<p><b>FRAG</b></p>
<p>The idea behind this “document fragment” tag is that it be used to wrap 3rd party content – ads,  widgets, and analytics. 3rd party content can have a severe impact on the containing page’s  performance due to additional HTTP requests, scripts that block  rendering and downloads, and added DOM nodes. Many of these factors can be mitigated by putting the 3rd party content  inside an iframe embedded in the top level HTML document. But iframes have constraints and drawbacks – they typically introduce  another HTTP request for the iframe’s HTML document, not all 3rd party  code snippets will work inside an iframe without changes (e.g.,  references to “document” in JavaScript might need to reference the  parent document), and some snippets (expando ads, suggest) can’t float  over the main page’s elements. Another path to mitigate these issues is to load the JavaScript  asynchronously, but many of these widgets use document.write and so must  be evaluated synchronously.</p>
<p>A compromise is to place 3rd party content in the top level HTML  document wrapped in a FRAG block. This approach degrades nicely – older browsers would ignore the FRAG tag  and handle these snippets the same way they do today. Newer browsers would parse the HTML in a separate document fragment. The FRAG content would not block the rendering of the top level  document. Snippets containing document.write would work without blocking the top  level document. This idea just started getting discussed in January 2010. Much more use case analysis and discussion is needed, culminating in a  proposed specification. (Credit to Alex Russell for the idea and name.)
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/steves-browser-performance-wishlist/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Souders blasts off 5 in a row</title>
		<link>http://ajaxian.com/archives/souders-blasts-off-5-in-a-row</link>
		<comments>http://ajaxian.com/archives/souders-blasts-off-5-in-a-row#comments</comments>
		<pubDate>Sun, 14 Feb 2010 15:32:52 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=8612</guid>
		<description><![CDATA[Steve Souders has done a weekly set of posts on browser quirks that have caught his eye. Here's the roundup:
Missing schema double download
Internet Explorer 7 &#038; 8 will download stylesheets twice if the http(s) protocol is missing. Interestingly, I rarely see anyone use "//stevesouders.com/images/book-84x110.jpg" but here is a case to watch out for it.
document.write scripts [...]]]></description>
			<content:encoded><![CDATA[<p>Steve Souders has done a weekly set of posts on browser quirks that have caught his eye. Here's the roundup:</p>
<p><a href="http://www.stevesouders.com/blog/2010/02/10/5a-missing-schema-double-download/">Missing schema double download</a></p>
<p>Internet Explorer 7 &#038; 8 will download stylesheets twice if the http(s) protocol is missing. Interestingly, I rarely see anyone use "//stevesouders.com/images/book-84x110.jpg" but here is a case to watch out for it.</p>
<p><a href="http://www.stevesouders.com/blog/2010/02/10/5b-document-write-scripts-block-in-firefox/">document.write scripts block in Firefox</a></p>
<blockquote><p>
Scripts loaded using document.write block other downloads in Firefox. Unfortunately, document.write was invented. That problem was made a bzillion times worse when ads decided to use document.write to insert scripts into the content publisher’s page. It’s one line of code:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-5');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-5">
<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;">document.<span style="color: #006600;">write</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">'&lt;script src=&quot;http://www.adnetwork.com/main.js&quot;&gt;&lt;<span style="color: #000099; font-weight: bold;">\/</span>script&gt;'</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>Fortunately, most of today’s newer browsers load scripts in parallel including scripts added via document.write. But a few weeks ago I noticed that Firefox 3.6 had some weird blocking behavior in a page with ads, and tracked it down to a script added using document.write.</p>
<p>The document.write scripts test page demonstrates the problem. It has four scripts. The first and second are inserted using document.write. The third and fourth are loaded the normal way (via HTML using SCRIPT SRC). All four scripts are configured to take 4 seconds to download. In IE8, Chrome 4, Safari 4, and Opera 10.10, the total page load time is ~4 seconds. All the scripts, even the ones inserted using document.write, are loaded in parallel. In Firefox, the total page load time is 12 seconds (tested on 2.0, 3.0, and 3.6). The first document.write script loads from 1-4 seconds, the second document.write scripts loads from 5-8 seconds, and the final two normal scripts are loaded in parallel from 9-12 seconds.<br />
</script></p></blockquote>
<p><a href="http://www.stevesouders.com/blog/2010/02/11/mediaprint-stylesheets/">media=print stylesheets</a></p>
<blockquote><p>
Stylesheets set with media=”print” still block rendering in Internet Explorer.</p>
<p>I’m surprised browsers haven’t gotten to the point where they skip downloading stylesheets for a different media type than the current one. I’ve asked some web devs but no one can think of a good reason for doing this. In the meantime, even if you have stylesheets with media="print" you might want to follow the advice of Page Speed and YSlow and put them in the document HEAD. Or you could try loading them dynamically.
</p></blockquote>
<p><a href="http://www.stevesouders.com/blog/2010/02/12/5d-dynamic-stylesheets/">dynamic stylesheets</a></p>
<blockquote><p>
You can avoid blocking rendering in IE if you load stylesheets using DHTML and setTimeout.</p>
<p>A few weeks ago I had a meeting with a company that makes a popular widget. One technique they used to reduce their widget’s impact on the main page was to load a stylesheet dynamically, something like this:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-6');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-6">
<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> link = document.<span style="color: #006600;">createElement</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">'link'</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;">link.<span style="color: #006600;">rel</span> = <span style="color: #3366CC;">'stylesheet'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">link.<span style="color: #006600;">type</span> = <span style="color: #3366CC;">'text/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;">link.<span style="color: #006600;">href</span> = <span style="color: #3366CC;">'/main.css'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">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>.<span style="color: #006600;">appendChild</span><span style="color:#006600; font-weight:bold;">&#40;</span>link<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>Most of my attention for the past year has been on loading scripts dynamically to avoid blocking downloads. I haven’t focused on loading stylesheets dynamically. When it comes to stylesheets, blocking downloads isn’t an issue – stylesheets don’t block downloads (except in Firefox 2.0). The thing to worry about when downloading stylesheets is that IE blocks rendering until all stylesheets are downloaded1, and other browsers might experience a Flash Of Unstyled Content (FOUC).
</p></blockquote>
<p><a href="http://www.stevesouders.com/blog/2010/02/12/5e-speculative-background-images/">Speculative background images</a></p>
<blockquote><p>
Chrome and Safari start downloading background images before all styles are available. If a background image style gets overwritten this may cause wasteful downloads.</p>
<p>When my office-mate, Steve Lamm, pointed out this behavior to me, my first reaction was “that’s wasteful!” I love prefetching, but I’m not a big fan of most prefetching implementations because they’re too aggressive – they err too far on the side of downloading resources that never get used. After my initial reaction, I thought about this some more. How frequently would this speculative background image downloading be wasteful? I went on a search and couldn’t find any popular web site that overwrote the background-image style. Not one. I’m not saying pages like this don’t exist, I’m just saying it’s very atypical.</p>
<p>On the other hand, this speculative downloading of background images can really help performance and the user’s perception of page speed.
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/souders-blasts-off-5-in-a-row/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>DOMTiming interface being implemented in Chromium and Firefox</title>
		<link>http://ajaxian.com/archives/domtiming-interface-being-implemented-in-chromium-and-firefox</link>
		<comments>http://ajaxian.com/archives/domtiming-interface-being-implemented-in-chromium-and-firefox#comments</comments>
		<pubDate>Fri, 12 Feb 2010 11:23:17 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=8593</guid>
		<description><![CDATA[When testing our applications for performance, how do we go about timing various parts and pieces? Normally we are forced to manually get Date.now / new Date().getTime() times and futz around. It isn't possible to get at timing info for important lifecycle events (e.g. can only start timing once JS is loaded.
This is where the [...]]]></description>
			<content:encoded><![CDATA[<p>When testing our applications for performance, how do we go about timing various parts and pieces? Normally we are forced to manually get <code>Date.now / new Date().getTime()</code> times and futz around. It isn't possible to get at timing info for important lifecycle events (e.g. can only start timing once JS is loaded.</p>
<p>This is where the <a href="http://dev.w3.org/2006/webapi/WebTiming/">Web Timing</a> API comes into play, which seems to be in the early process of implementation in Chromium and Firefox.</p>
<p>With the API there is access to <code>window.timing</code> and <code>element.timing</code>.</p>
<p>An example of using the global window.timing:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-9');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-9">
<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> navigation = timing<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#93;</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>navigation.<span style="color: #006600;">document</span>.<span style="color: #006600;">load</span>&gt; <span style="color:#800000;">0</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; <span style="color: #003366; font-weight: bold;">var</span> page_load_time = navigation.<span style="color: #006600;">document</span>.<span style="color: #006600;">load</span> - navigation.<span style="color: #006600;">navigationStart</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: #000066; font-weight: bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>navigation.<span style="color: #006600;">navigationType</span> == navigation.<span style="color: #006600;">NAVIGATION_LINK</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; console.<span style="color: #006600;">log</span> <span style="color:#006600; font-weight:bold;">&#40;</span>page_load_time<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; <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;">&#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>
</ol>
</div>
</div>
</div>
<p>Within a timing result you have access to a slew of information:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-10');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-10">
<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;">interface DOMTiming <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; 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; 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; 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; 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; 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; 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; 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; 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; 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; readonly attribute unsigned longlong load;</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; readonly attribute unsigned longlong parseStart;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; readonly attribute unsigned longlong parseEnd;</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>I am sure that Steve is happy :)</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/domtiming-interface-being-implemented-in-chromium-and-firefox/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Canvas Benchmark</title>
		<link>http://ajaxian.com/archives/canvas-benchmark</link>
		<comments>http://ajaxian.com/archives/canvas-benchmark#comments</comments>
		<pubDate>Thu, 28 Jan 2010 11:09:10 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Canvas]]></category>
		<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=8499</guid>
		<description><![CDATA[
The Freeciv.net crew has benchmarked a path in their canvas game. It is one data point, and tests more than just Canvas itself because a lot of code is running in the game. Thus, it ends up testing the union of a particular JavaScript path and the rendering of the canvas.
Here are the results:

With Bespin [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://freeciv.net/images/screenshot1.jpg"/></p>
<p>The Freeciv.net crew has <a href="http://code.google.com/p/freeciv-forever/wiki/FreecivBenchmarkResults">benchmarked a path in their canvas game</a>. It is one data point, and tests more than just Canvas itself because a lot of code is running in the game. Thus, it ends up testing the union of a particular JavaScript path and the rendering of the canvas.</p>
<p>Here are the results:</p>
<p><img src="http://ajaxian.com/wp-content/images/canvasbenchmark.png" alt="canvasbenchmark" title="canvasbenchmark" width="480" height="451" class="alignnone size-full wp-image-8500"/></p>
<p>With Bespin we had slightly different results, and the bulk of the bottleneck was in the blitting of the canvas. Optimizations were made to canvas over the initial phase of Bespin so the various browsers would leap frog each other. Good times :)</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/canvas-benchmark/feed</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>Pure CSS bar charts as a simple API</title>
		<link>http://ajaxian.com/archives/pure-css-bar-charts-as-a-simple-api</link>
		<comments>http://ajaxian.com/archives/pure-css-bar-charts-as-a-simple-api#comments</comments>
		<pubDate>Fri, 15 Jan 2010 13:19:05 +0000</pubDate>
		<dc:creator>Chris Heilmann</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Front Page]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[charts]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=8453</guid>
		<description><![CDATA[I am right now working on a high-traffic project that will run in a sandbox that doesn't allow me to pull third party JavaScript or use canvas/Flash. Yet I need to generate bar charts from a set of data.

The solution to me was to create the charts from HTML using CSS. There have been some [...]]]></description>
			<content:encoded><![CDATA[<p>I am right now working on a high-traffic project that will run in a sandbox that doesn't allow me to pull third party JavaScript or use canvas/Flash. Yet I need to generate bar charts from a set of data.</p>
<p><a href="http://icant.co.uk/csscharts"><img src="http://farm5.static.flickr.com/4034/4275838221_5ed55f57a6.jpg" alt="Pure CSS bar charts"/></a></p>
<p>The solution to me was to create the charts from HTML using CSS. There have been some <a href="http://meyerweb.com/eric/css/edge/bargraph/demo.html">solutions</a> <a href="http://www.splintered.co.uk/experiments/archives/css_bar_graphs/">for</a> <a href="http://www.standards-schmandards.com/exhibits/barchart/">this</a> <a href="http://www.cssplay.co.uk/menu/barchart.html">problem</a> <a href="http://speckyboy.com/2009/02/04/16-usable-css-graph-and-bar-chart-tutorials-and-techniques/">already</a> but I wanted something very simple and easy to maintain. Hence all the markup I am using is this:</p>
<div class="igBar"><a href="javascript:showCodeTxt('xml-15');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">XML:</span>
<div id="xml-15">
<div class="xml">
<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: #009900;"><span style="font-weight: bold; color: black;">&lt;ul<span style="font-weight: bold; color: black;">&gt;</span></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; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;li<span style="font-weight: bold; color: black;">&gt;</span></span></span><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;span<span style="font-weight: bold; color: black;">&gt;</span></span></span>400<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/span<span style="font-weight: bold; color: black;">&gt;</span></span></span><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/li<span style="font-weight: bold; color: black;">&gt;</span></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;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;li<span style="font-weight: bold; color: black;">&gt;</span></span></span><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;span<span style="font-weight: bold; color: black;">&gt;</span></span></span>20<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/span<span style="font-weight: bold; color: black;">&gt;</span></span></span><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/li<span style="font-weight: bold; color: black;">&gt;</span></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; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;li<span style="font-weight: bold; color: black;">&gt;</span></span></span><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;span<span style="font-weight: bold; color: black;">&gt;</span></span></span>30<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/span<span style="font-weight: bold; color: black;">&gt;</span></span></span><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/li<span style="font-weight: bold; color: black;">&gt;</span></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;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;li<span style="font-weight: bold; color: black;">&gt;</span></span></span><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;span<span style="font-weight: bold; color: black;">&gt;</span></span></span>233<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/span<span style="font-weight: bold; color: black;">&gt;</span></span></span><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/li<span style="font-weight: bold; color: black;">&gt;</span></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;"><span style="font-weight: bold; color: black;">&lt;/ul<span style="font-weight: bold; color: black;">&gt;</span></span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>Instead of hard-coding any of the trickery necessary I wrote a PHP script to generate the HTML, the styles and do all the math. So all that is needed to render one of the charts is the following code:</p>
<div class="igBar"><a href="javascript:showCodeTxt('php-16');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">PHP:</span>
<div id="php-16">
<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;"><span style="color:#000000; font-weight:bold;">&lt;?php</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:#0000FF;">$values</span> = <span style="color:#FF0000;">'400,20,30,233,312,78,20,67'</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:#0000FF;">$height</span> = <span style="color:#800000;">100</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:#0000FF;">$width</span> = <span style="color:#800000;">600</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:#0000FF;">$bargap</span> = <span style="color:#800000;">0</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:#616100;">include</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'csscharts.php'</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:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>Of course, this can also be turned into a web service - you can get the chart with the following URL:</p>
<p><a href="http://icant.co.uk/csscharts/csscharts.php?values=400,20,30,233,312,78,20,67&#038;height=100&#038;width=600&#038;bargap=0">http://icant.co.uk/csscharts/csscharts.php?values=400,20,30,233,312,78,20,67&#038;height=100&#038;width=600&#038;bargap=0</a></p>
<p>And if you specify JSON as the format you get it with a <code>callback</code> to a function called <code>csscharts</code>:</p>
<p><a href="http://icant.co.uk/csscharts/csscharts.php?values=400,20,30,233,312,78,20,67&#038;format=json">http://icant.co.uk/csscharts/csscharts.php?values=400,20,30,233,312,78,20,67&#038;format=json</a></p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-17');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-17">
<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;">csscharts<span style="color:#006600; font-weight:bold;">&#40;</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;">&#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; chart:<span style="color: #3366CC;">"&lt;ul class=<span style="color: #000099; font-weight: bold;">\"</span>barchart<span style="color: #000099; font-weight: bold;">\"</span> [… the rest of the html …]&lt;/ul&gt;"</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;"><span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>That way you can use it in JavaScript:</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;">&lt;script&gt;</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;">function</span> csscharts<span style="color:#006600; font-weight:bold;">&#40;</span>o<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; <span style="color: #003366; font-weight: bold;">var</span> container = document.<span style="color: #006600;">getElementById</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">'container'</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; c.<span style="color: #006600;">innerHTML</span> = o.<span style="color: #006600;">chart</span> + c.<span style="color: #006600;">innerHTML</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;">&lt;/script&gt;</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;">&lt;script src=<span style="color: #3366CC;">"http://icant.co.uk/csscharts/csscharts.php?values=400,20,30,233,312,78,20,67&amp;format=json"</span>&gt;&lt;/script&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p>You can <a href="http://icant.co.uk/csscharts/csscharts-demo.php">see some demos here</a>, get <a href="http://icant.co.uk/csscharts/">detailed info about the CSS trickery used</a> and of course <a href="http://github.com/codepo8/CSScharts">download the code on GitHub.</a></ul>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/pure-css-bar-charts-as-a-simple-api/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>WebKit Inspector Audit View</title>
		<link>http://ajaxian.com/archives/webkit-inspector-audit-view</link>
		<comments>http://ajaxian.com/archives/webkit-inspector-audit-view#comments</comments>
		<pubDate>Wed, 30 Dec 2009 11:35:09 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=8364</guid>
		<description><![CDATA[The WebKit Inspector tool has a new tab, the Audits panel which aims to be like Google PageSpeed and YSlow! built right in.
A little crude, but good to see:


]]></description>
			<content:encoded><![CDATA[<p>The WebKit Inspector tool has a new tab, the <a href="https://bugs.webkit.org/show_bug.cgi?id=31665">Audits panel</a> which aims to be like Google PageSpeed and YSlow! built right in.</p>
<p>A little crude, but good to see:</p>
<p><img src="https://bug-31665-attachments.webkit.org/attachment.cgi?id=45393" width="480"/></p>
<p><img src="https://bug-31665-attachments.webkit.org/attachment.cgi?id=45391" width="480"/></p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/webkit-inspector-audit-view/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Performance of data URIs</title>
		<link>http://ajaxian.com/archives/performance-of-data-uris</link>
		<comments>http://ajaxian.com/archives/performance-of-data-uris#comments</comments>
		<pubDate>Sun, 13 Dec 2009 00:46:25 +0000</pubDate>
		<dc:creator>Michael Mahemoff</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=8246</guid>
		<description><![CDATA[Rob Flaherty has done a little experimenting with data URIs and performance. The study only looked at Firefox 3.5 with empty cache, but the results were interesting for the questions they raise as much as the answers the provide.
He used a CSS file with 31 images and converted them all to data URIs using Nick [...]]]></description>
			<content:encoded><![CDATA[<p>Rob Flaherty has done a little <a href="http://www.ravelrumba.com/blog/data-uris-for-css-images-more-tests-more-questions/">experimenting with data URIs and performance</a>. The study only looked at Firefox 3.5 with empty cache, but the results were interesting for the questions they raise as much as the answers the provide.</p>
<p>He used a CSS file with 31 images and converted them all to data URIs using Nick Zakas's <a href="http://github.com/nzakas/cssembed">CSSEmbed</a>. For an extra variant, he used <a href="http://duris.ru/">DURIS</a> to extract the data URIs to a separate CSS file so that the basic CSS in &lt;head&gt; becomes much smaller and therefore loads much faster.</p>
<p>All three scenarios yielded similar performance - with HTTPWatch, the times were 1.35s, 1.13s, and 1.13s. So the two data URI scenarios were only marginally better. But more interestingly, a commenter from South Africa chimed in with wildly different results (using Firebug): 4.04s, 1.44s, 1.92s. The implication is clear: latency can be a big factor in some cases, and round-tripping to fetch 31 images is going to bring that out.</p>
<p>Another interesting factor is perceived speed. This is, after all, arguably the most important thing when it comes to performance. Although the two data URI scenarios completed in the same speed, the second setup felt faster because it got the images out of the way and allowed the main stylesheet to load fast. The data URI images were then loaded in a stylesheet at the bottom of the page, after a script had been loaded.</p>
<p>The study also raises questions about data URI loading. A commenter posted a <a href="https://twitpic.com/t15ai/full">waterfall</a> showing the data URI images take significantly longer to load than regular downloaded images. This is the kind of thing that needs more research and why the study is interesting because of the questions it raises.</p>
<p>Rob also posted a study recently on <a href="http://www.ravelrumba.com/blog/a-look-at-how-browsers-download-and-render-css-background-images/">background-image performance</a> in various browsers.</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/performance-of-data-uris/feed</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>The End of Days for &#8220;View Source&#8221;?</title>
		<link>http://ajaxian.com/archives/the-end-of-days-for-view-source</link>
		<comments>http://ajaxian.com/archives/the-end-of-days-for-view-source#comments</comments>
		<pubDate>Thu, 03 Dec 2009 15:40:20 +0000</pubDate>
		<dc:creator>Michael Mahemoff</dc:creator>
				<category><![CDATA[Editorial]]></category>
		<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=8080</guid>
		<description><![CDATA[
"View Source is your friend", we've learned countless times as web developers. It's something special about web development that we can seamlessly lift the covers on anything we see and find out how the sausage is made. And it gets even better with great tools to interrogate the system in real-time. This capability has helped [...]]]></description>
			<content:encoded><![CDATA[<p><img alt="Apocalypse 2012" src="http://www.collider.com/wp-content/image-base/Movies/T/Two_2012/posters/2012%20movie%20poster%20slice.jpg" title="Apocalypse 2012" width="507" height="193" /></p>
<p>"View Source is your friend", we've learned countless times as web developers. It's something special about web development that we can seamlessly lift the covers on anything we see and find out how the sausage is made. And it gets even better with <a href=" http://getfirebug.com">great</a> <a href="http://webkit.org/blog/41/introducing-the-web-inspector/">tools</a> to interrogate the system in real-time. This capability has helped us evolve practices and patterns, and contributed to the production of many a fine browser extension and Greasemonkey script.</p>
<p>Our friend might sadly be going the way of the blink tag. View Source has always worked because the standard development model is to put up some static Javascript files on a server somewhere and serve them out. That model is changing though; performance is a <a href="http://conferences.oreilly.com/velocityonline">very</a> <a href="http://www.scalecamp.org.uk/">hot</a> topic right now, and View Source is playing victim to that trend.</p>
<p>Google's <a href="http://googleblog.blogspot.com/2009/06/lets-make-web-faster.html">Let's Make the Web Faster</a> initiative is a case in point. Here is a multi-pronged attack on the performance issue, involving new protocols (SPDY), tools (PageSpeed), browser improvements (Chrome), on-demand loading (Closure), and - most pertinent - compression techniques (Closure again). And we ain't seen nothing yet; there's every reason to believe Google will soon be putting its money where its mouth is, by <a href="http://gigaom.com/2009/11/22/should-web-page-speed-influence-google-pagerank/">rewarding faster sites with higher rankings</a>. (I guess I was alone in assuming they always did that.) While performance <em>should</em> always be a consideration for site owners, a dangling SEO carrot would no doubt convert the best of intentions into the most concrete of actions.</p>
<p>Site owners can't (much) control factors such as browser choice and browser efficiency, but they <em>can</em> get their own performance-fu in order, and code compression is low-hanging fruit. Looking at the <a href="http://www.alexa.com/topsites">top 20-ranked sites</a>, filtering only English-language sites, I found the very top  guys (Google, Facebook, Yahoo, YouTube, Windows Live) predominately using Javascript compression, with the others not using it much, if at all. I expect most of them to be using it in the next 12-24 months.</p>
<p>In addition to compression, there is also obfuscation. With Javascript being used for more complex tasks and replacing desktop functionality, more companies will be wondering about all that intellectual property sitting in plain view. (And let's not mention the security-by-obscurity fans, who will also go this route, however flawed their thinking.)</p>
<p>Is it all bad? No. There's a much healthier respect for <a href="http://microformats.org/wiki/posh">plain old semantic HTML</a> these days, which means HTML documents should be View Sourcier now than ever before. (CSS, not so much, with compression also likely to grow.)  If I had to choose between one or the other, I'd take clear HTML over clear Javascript. Also, we will probably find the majority of sites in the long tail won't feel the need to do anything about their code (but the ones who do make efforts are probably the ones with the most interesting things to look at). Also, the aforementioned tools, which do things like XHR sniffing, will help us to understand from a "black box" perspective even if we can't peer into the code. Hopefully, there will also be more attention paid towards Javascript beautifiers as well, to make sense of compressed code.</p>
<p>I can't speculate on the waning of View Source without mentioning the tremendous counter-balancing act played out by  Open Source. From the get-go, open source has played a vital role in Ajax, with individuals and companies releasing code for all sorts of reasons. Most of this is library and framework code, rather than production-ready applications, so we might lose something there, but we still have much to gain from the ever-growing corpus of code that's out there, free to be studied and incorporated into our own applications.</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/the-end-of-days-for-view-source/feed</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
		<item>
		<title>Google Analytics unblocks the Web w/ Async support</title>
		<link>http://ajaxian.com/archives/google-analytics-unblocks-the-web-w-async-support</link>
		<comments>http://ajaxian.com/archives/google-analytics-unblocks-the-web-w-async-support#comments</comments>
		<pubDate>Wed, 02 Dec 2009 11:21:01 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=8089</guid>
		<description><![CDATA[I heard a huge cheer from the Internet today and found that Google Analytics has launched async mode which finally unclogs our browsers from blocking.
Steve Souders must have had the loudest cheer, and wrote up his view:

The pain of loading JavaScript files is that they block the page from rendering and block other resources from [...]]]></description>
			<content:encoded><![CDATA[<p>I heard a huge cheer from the Internet today and found that <a href="http://googlecode.blogspot.com/2009/12/google-analytics-launches-asynchronous.html">Google Analytics has launched async mode</a> which finally unclogs our browsers from blocking.</p>
<p>Steve Souders must have had the loudest cheer, and <a href="http://www.stevesouders.com/blog/2009/12/01/google-analytics-goes-async/">wrote up his view</a>:</p>
<blockquote><p>
The pain of loading JavaScript files is that they block the page from rendering and block other resources from downloading. There are workarounds to these problems. Chapter 4 of <a href="http://www.amazon.com/Even-Faster-Web-Sites-Performance/dp/0596522304">Even Faster Web Sites</a> describes six techniques for <a href="http://www.stevesouders.com/blog/2009/04/27/loading-scripts-without-blocking/">Loading Scripts Without Blocking</a>. One of those, the Script DOM Element approach, is the technique used in the new Google Analytics async pattern. Google Analytics’ ga.js file is a perfect example of a script that should be loaded asynchronously - it doesn’t add any content to the page, so we want to load it without blocking the images and stylesheets that give users what they really came to see.</p>
<p><b>Improved Uptime</b></p>
<p>What happens if a script takes a long time to load, or fails to load? Because scripts block rendering, users are left staring at an empty page. Google Analytics has an amazing infrastructure behind it, but any resource, especially from third parties, should be added cautiously. It’s great that the GA team is evangelizing a pattern that allows the web site to render while ga.js is being downloaded.
</p></blockquote>
<p>To get going, simply change your ga script code to follow the pattern:</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;"><span style="color: #003366; font-weight: bold;">var</span> _gaq = _gaq || <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</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;">_gaq.<span style="color: #006600;">push</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color: #3366CC;">'_setAccount'</span>, <span style="color: #3366CC;">'UA-XXXXX-X'</span><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;">_gaq.<span style="color: #006600;">push</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color: #3366CC;">'_trackPageview'</span><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;">&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;">&#40;</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;"><span style="color: #003366; font-weight: bold;">var</span> ga = 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;">ga.<span style="color: #006600;">src</span> = <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">'https:'</span> == document.<span style="color: #006600;">location</span>.<span style="color: #006600;">protocol</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;">'https://ssl'</span> : <span style="color: #3366CC;">'http://www'</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: #3366CC;">'.google-analytics.com/ga.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;">ga.<span style="color: #006600;">setAttribute</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">'async'</span>, <span style="color: #3366CC;">'true'</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;">document.<span style="color: #006600;">documentElement</span>.<span style="color: #006600;">firstChild</span>.<span style="color: #006600;">appendChild</span><span style="color:#006600; font-weight:bold;">&#40;</span>ga<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><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>It’s extremely cool to see this pattern being evangelized for such a major piece of the Internet. A few items of note:</p>
<ul>
<li>Obviously, you have to replace “UA-XXXXX-X” with your ID.
</li>
<li>Since ga.js is being loaded asynchronously, there has to be a way for web site owners to couple their desired GA functions with the code when it finishes loading. This is done by pushing commands onto the Google Analytics queue object, _gaq.
</li>
<li>Once all your callback commands are queued up, the ga.js script gets loaded. This is wrapped inside an anonymous function to avoid any namespace conflicts.
</li>
<li>Inside the anonymous function is where we see the Script DOM Element approach being used - with two nice improvements. A ’script’ element is created and its SRC is set to the appropriate ga.js URL. Looking ahead to support of asynchronous scripts in HTML5, the ‘async’ attribute is set to ‘true’. Very nice! The main benefit of this is it tells the browser that subsequent scripts can be executed immediately - they don’t have to wait for ga.js. The last line adds the script element to the DOM. This is what triggers the actual download of ga.js. In most of my code I do document.getElementsByTagName(”head”)[0].appendChild, but that fails if the document doesn’t have a head element. This is a more robust implementation.
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/google-analytics-unblocks-the-web-w-async-support/feed</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>Statsy &#8211; find those wasted bytes with a bookmarklet</title>
		<link>http://ajaxian.com/archives/statsy-find-those-wasted-bytes-with-a-bookmarklet</link>
		<comments>http://ajaxian.com/archives/statsy-find-those-wasted-bytes-with-a-bookmarklet#comments</comments>
		<pubDate>Mon, 30 Nov 2009 12:14:27 +0000</pubDate>
		<dc:creator>Chris Heilmann</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[bookmarklet]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=8060</guid>
		<description><![CDATA[Stoyan Stefanov is all about the performance of web products. One small tool that gives you a bit of insight as to where you can optimize is a new bookmarklet he released today called statsy.
If you run statsy on a web site you get the following insights:

JS attributes (e.g. onclick) - this is the sum [...]]]></description>
			<content:encoded><![CDATA[<p>Stoyan Stefanov is all about the performance of web products. One small tool that gives you a bit of insight as to where you can optimize is a new bookmarklet he released today called <a href="http://www.phpied.com/statsy-more-data-points-for-markup-quality/">statsy</a>.</p>
<p>If you run statsy on a web site you get the following insights:</p>
<ul>
<li><code>JS attributes (e.g. onclick)</code> - this is the sum of all <code>onclick</code>, <code>onmouseover</code> and so on including the attribute names. So for example <code>&lt;a onclick="#"&gt;</code> is 11 characters (bytes) of JavaScript attributes code</li>
<li><code>CSS style attributes</code> - the sum of all <code>style="..."</code></li>
<li><code>Inline JS</code> - the sum of all the contents of all script tags (excluding the tag itself)</li>
<li><code>Inline CSS</code> - sum of all <code>&lt;style&gt;</code> tag contents</li>
<li><code>All innerHTML</code> - this is <code>document.documentElement.innerHTML.length</code>, it should be close to the ungzipped size of a page, provided the page is not doing a lot of DOM manipulation</li>
<li><code># DOM elements</code> - the total number of elements on the page is counted simply using <code>document.getElementsByTagName('*').length</code></li>
</ul>
<p>On Ajaxian, this is the result:</p>
<p><a href="http://www.flickr.com/photos/codepo8/4147138168/"><img src="http://farm3.static.flickr.com/2643/4147138168_86ea774345.jpg" alt="Statsy on Ajaxian by  you."/></a></p>
<p>You can install statsy by dragging the following link to your link bar: <a href="javascript:(function(){var%20s%20=%20document.createElement('script');%20s.src%20=%20'http://phpied.com/files/bookmarklets/somestats.js';%20document.getElementsByTagName('head')[0].appendChild(s);})()">Statsy</a> and the <a href="http://phpied.com/files/bookmarklets/somestats.js">source is also available</a>.</p>
<p>Nothing earth-shattering but a good tool to use together with YSLow or PageSpeed.</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/statsy-find-those-wasted-bytes-with-a-bookmarklet/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>LABjs gets &#8220;Even Faster&#8221; with version 1.0</title>
		<link>http://ajaxian.com/archives/labjs-gets-even-faster-with-version-1-0</link>
		<comments>http://ajaxian.com/archives/labjs-gets-even-faster-with-version-1-0#comments</comments>
		<pubDate>Mon, 30 Nov 2009 11:32:51 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=8053</guid>
		<description><![CDATA[We have posted about LABjs before, the library that aims to be able to effectively load any script resource(s), from any location, into any page, at any time. It loads them all as parallel as the browser will allow, but maintains execution order when you express the need to do so in the usage of [...]]]></description>
			<content:encoded><![CDATA[<p>We have posted about LABjs before, the library that aims to be able to effectively load any script resource(s), from any location, into any page, at any time. It loads them all as parallel as the browser will allow, but maintains execution order when you express the need to do so in the usage of the API, for keeping dependencies safe.</p>
<p>At JSConf.EU in Berlin, I saw Steve Souders and Kyle Simpson riffing on how to make LABjs follow the research that Steve (<a href="http://www.amazon.com/Even-Faster-Web-Sites-Performance/dp/0596522304">in his newest book</a>) and Kyle have done.</p>
<p>There were issues in the past, but <a href="http://blog.getify.com/2009/11/labjs-new-hotness-for-script-loading/">we now have a new release of LABjs</a> that does the right thing, as long as you <code>wait()</code>:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-23');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-23">
<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;">$LAB</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;">script</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"framework.js"</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #006600;">wait</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;">.<span style="color: #006600;">script</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"plugin.framework.js"</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;">script</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"myplugin.framework.js"</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #006600;">wait</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;">.<span style="color: #006600;">script</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"init.js"</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>Give it a whirl, and read the full post for details on performance and issues with flashing in before behaviour has been added... which leads us to the cavaet on <a href="http://blog.getify.com/2009/11/why-dom-ready-still-sucks/">jQuery and DOM ready</a>.</p>
<p>Also, if you think that you should be just concat'ing all of the files into one, see why Kyle thinks you should <a href="http://blog.getify.com/2009/11/labjs-why-not-just-concat/">potentially think again</a>.</p>
<p>As I wrote this another library called <a href="http://github.com/berklee/nbl/">NBL</a> came in from "Berklee". He told us:</p>
<blockquote><p>
The other day I tasked myself with rewriting our company's website in HTML5 and I really wanted to improve performance all across the board. So after rewriting the HTML and CSS, I looked to JavaScript lazy loading to increase performance. After searching for a small library to do this and not finding anything not requiring jQuery, or unable to handle network timeouts, I decide to write my own non-blocking lazy loader.</p>
<p>It's called NBL and comes down to 1187 bytes minified. It runs stand-alone and has several options that I could not find in any other library:</p>
<p>1. It can load plugins for your JavaScript framework *after* the framework has been loaded (jQuery is considered the default, but you can override it with any other framework and keep this behaviour).</p>
<p>2. You can provide a callback function that fires when all scripts are loaded, or if you use jQuery, the callback will be fired by jQuery's document.ready() function (unless the page finishes before jQuery initialises, in which case it fires when all scripts are loaded).</p>
<p>3. In case of network latency (or faulty urls), NBL will fire the callback function after a timeout (by default 1200ms).</p>
<p>4. It does not need to be called, it can be configured completely from the script tag itself, like this:</p>
<div class="igBar"><a href="javascript:showCodeTxt('html-24');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">HTML:</span>
<div id="html-24">
<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</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">"nbl.js"</span> opt=<span style="color: #ff0000;">"{ urchin: 'http://www.google-analytics.com/urchin.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;"><span style="color: #ff0000;">plugins: [ 'jquery.lightbox.min.js', 'jquery.carousel.min.js' ], ready: my_ready_function }"</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>
</ol>
</div>
</div>
</div>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/labjs-gets-even-faster-with-version-1-0/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Full Frontal &#8216;09: Jake Archibald on Performance Optimisation</title>
		<link>http://ajaxian.com/archives/full-frontal-09-jake-archibald-on-performance-optimisation</link>
		<comments>http://ajaxian.com/archives/full-frontal-09-jake-archibald-on-performance-optimisation#comments</comments>
		<pubDate>Fri, 20 Nov 2009 17:11:11 +0000</pubDate>
		<dc:creator>Michael Mahemoff</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=7979</guid>
		<description><![CDATA[Jake explains no-one likes waiting, and people are multi-threaded (except when they have to sneeze). Yet, we're stuck with a single-threaded language for the most part; and we still face the legacy of a DOM standard from another era (DOM Level 1 - 1997). This talk provides some optimisation tips, backed by Jake's cross-browser experiments.
Jake's [...]]]></description>
			<content:encoded><![CDATA[<p>Jake explains no-one likes waiting, and people are multi-threaded (except when they have to sneeze). Yet, we're stuck with a single-threaded language for the most part; and we still face the legacy of a DOM standard from another era (DOM Level 1 - 1997). This talk provides some optimisation tips, backed by Jake's cross-browser experiments.</p>
<p><a href="http://jakearchibald.co.uk/jsperformance/">Jake's slides and research are online.</a></p>
<h3>Optimise Where it Matters</h3>
<p>Jake explains the importance of speeding things up where it really matters.</p>
<p>Doug Crockford has pointed out that in Javascript, bitwise operations aren't close to the hardware, which stands in contrast to other languages. In fact, if you look at it, bitwise operations can still be faster than alternative operations; Jake shows an example where bitwise parsing of hex codes is faster than bitwise. The question is, how much faster? In many cases, such as this example, your energy is better spent on optimising big things.</p>
<h3>Avoid eval() Where Possible</h3>
<p>Jake says avoid eval() where possible. Thinking about what functions eval, here's a brain teaser: what will the following output?</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-27');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-27">
<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> msg = <span style="color: #3366CC;">"spatchcock"</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: #003366; font-weight: bold;">function</span> doStuff<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; <span style="color: #000066;">alert</span><span style="color:#006600; font-weight:bold;">&#40;</span>msg<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; <span style="color: #000066; font-weight: bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #003366; font-weight: bold;">false</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> msg=<span style="color: #3366CC;">"spotted dick"</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:#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;">&#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;">doStuff<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>Wait for it ... the answer is "undefined". Javascript does look ahead and create space for the local variable. So during the running of the function, there's no need to allocate space for the variable and the browser can optimise for that, but if you use "eval", the optimisation goes away. So avoid eval().</p>
<h3>Prefer innerHTML to DOM</h3>
<p>Jake shows a comparison of innerHTML versus DOM Level 1. In IE, DOM manipulation is much slower, because of the sync process between the two. The differential gets even worse when creating elements. Webkit has optimised sync between HTML and DOM, hence less difference, so it's not as bad, but create example is still slower with DOM. So from a performance perspective, best practice is construct the HTML and use innerHTML.</p>
<h3>Selectors</h3>
<p>It's educational to look at the implementation of selector libraries. Jake shows a comparison - IE7 is vastly more slow in this case. It doesn't support getElementsByClassName, querySelectorAll, evaluate; and it does support getElementById, but that's not used by sizzle for this query. So getElementsByTagName is all that's left; and if you knew that, and the implications, you could have made the query much faster.</p>
<h3>Benchmarking</h3>
<p>Pretty simple.</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> duration;</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;">start = <span style="color: #003366; font-weight: bold;">new</span> Date<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;">thingToTest<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;">duration = <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> - start;</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>However, timing isn't so accurate, so stick it in a function and run it many times.</p>
<p>Too easy ... so go benchmark and report your findings.</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/full-frontal-09-jake-archibald-on-performance-optimisation/feed</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Resource Packages; Making a faster Web via packaging</title>
		<link>http://ajaxian.com/archives/resource-packages-making-a-faster-web-via-packaging</link>
		<comments>http://ajaxian.com/archives/resource-packages-making-a-faster-web-via-packaging#comments</comments>
		<pubDate>Tue, 17 Nov 2009 11:23:55 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=7948</guid>
		<description><![CDATA[PLAIN TEXT
HTML:




&#160;


&#60;link rel="resource-package" href="site-resources.zip" /&#62;


&#160;





What if we could agree on a simple backwards compatible approach to packaging Web resources so the browser could suck down the puppies in one go?
Alexander Limi (of Plone and Firefox UX fame) has been thinking about this for awhile, and has gotten his latest proposal out there which defines a [...]]]></description>
			<content:encoded><![CDATA[<div class="igBar"><a href="javascript:showCodeTxt('html-30');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">HTML:</span>
<div id="html-30">
<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/link.html"><span style="color: #000000; font-weight: bold;">&lt;link</span></a> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">"resource-package"</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">"site-resources.zip"</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>What if we could agree on a simple backwards compatible approach to packaging Web resources so the browser could suck down the puppies in one go?</p>
<p>Alexander Limi (of Plone and Firefox UX fame) has been thinking about this for awhile, and has <a href="http://limi.net/articles/resource-packages/">gotten his latest proposal out there</a> which defines a simple way to package things.</p>
<p>It builds on existing tech: zip, manifests, and the like.... and degrades nicely.</p>
<p>This is so much nicer than spriting hacks, but does have its own issues:</p>
<ul>
<li>In theory the browser could sometimes render faster by grabbing items in parallel
</li>
<li>Mobile caches may be messed up (as larger than a cache size, like say iPhone's 256k)
</li>
<li>What if the zip gets out of date with the other resources?
</li>
<li>Ideally tools (and in fact even web server modules) would auto generate this stuff
</li>
</ul>
<p>Although not perfect, for the majority case this could be a real boon to performance. What do you say <a href="http://twitter.com/souders">Steve</a>?</p>
<p>Oh, and it sounds like Firefox will implement this in 3.7!</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/resource-packages-making-a-faster-web-via-packaging/feed</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>SPDY: Make HTTP chatter a lot faster</title>
		<link>http://ajaxian.com/archives/spdy-make-http-chatter-a-lot-faster</link>
		<comments>http://ajaxian.com/archives/spdy-make-http-chatter-a-lot-faster#comments</comments>
		<pubDate>Thu, 12 Nov 2009 18:54:36 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=7922</guid>
		<description><![CDATA[Mike Belshe of Google has been working on SPDY an optimized use of HTTP:

 It is designed specifically for minimizing latency through features such as multiplexed streams, request prioritization and HTTP header compression.
We started working on SPDY while exploring ways to optimize the way browsers and servers communicate. Today, web clients and servers speak HTTP. [...]]]></description>
			<content:encoded><![CDATA[<p>Mike Belshe of Google has been working on <a href="http://blog.chromium.org/2009/11/2x-faster-web.html">SPDY</a> an optimized use of HTTP:</p>
<blockquote><p>
 It is designed specifically for minimizing latency through features such as multiplexed streams, request prioritization and HTTP header compression.</p>
<p>We started working on SPDY while exploring ways to optimize the way browsers and servers communicate. Today, web clients and servers speak HTTP. HTTP is an elegantly simple protocol that emerged as a web standard in 1996 after a series of experiments. HTTP has served the web incredibly well. We want to continue building on the web's tradition of experimentation and optimization, to further support the evolution of websites and browsers. So over the last few months, a few of us here at Google have been experimenting with new ways for web browsers and servers to speak to each other, resulting in a prototype web server and Google Chrome client with SPDY support.</p>
<p>So far we have only tested SPDY in lab conditions. The initial results are very encouraging: when we download the top 25 websites over simulated home network connections, we see a significant improvement in performance - pages loaded up to 55% faster. There is still a lot of work we need to do to evaluate the performance of SPDY in real-world conditions. However, we believe that we have reached the stage where our small team could benefit from the active participation, feedback and assistance of the web community.
</p></blockquote>
<p>It is great to see this in the wild. We have seen delta compression from Google before (used in Google Toolbar but not talked about too much) but I am glad to see this getting out there early stage, which gives all browsers/servers a chance to participate and play.</p>
<p>However, I have an issue with <a href="http://src.chromium.org/viewvc/chrome/trunk/src/net/flip/">one line of code....</a> ;)</p>
<p>Great write-ups here:</p>
<ul>
<li>Alex Russell: <a href="http://alex.dojotoolkit.org/2009/11/spdy-the-web-only-faster/">SPDY: The Web, Only Faster</a>
</li>
<li>Mark Nottingham: <a href="http://www.mnot.net/blog/2009/11/13/flip">Will HTTP/2.0 Happen After All?</a>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/spdy-make-http-chatter-a-lot-faster/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>jQuery Bondage</title>
		<link>http://ajaxian.com/archives/jquery-bondage</link>
		<comments>http://ajaxian.com/archives/jquery-bondage#comments</comments>
		<pubDate>Wed, 04 Nov 2009 11:16:24 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=7797</guid>
		<description><![CDATA[
When your browser freezes on you on some random web page, there's a pretty good chance its caused by the very JavaScript designed to improve your experience.

Good 'ole JavaScript performance. Sebastian Ruiz of Atlassian recently worked on a UI rewrite of two of their products (FishEye and Crucible) and found some interesting solutions to problems [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>
When your browser freezes on you on some random web page, there's a pretty good chance its caused by the very JavaScript designed to improve your experience.
</p></blockquote>
<p>Good 'ole JavaScript performance. Sebastian Ruiz of Atlassian recently worked on a UI rewrite of two of their products (<a href="http://www.atlassian.com/software/fisheye/">FishEye</a> and <a href="http://www.atlassian.com/software/crucible/">Crucible</a>) and found some interesting solutions to problems that came up:</p>
<blockquote>
<h2>The event binder</h2>
<p>A simple jQuery event bind selector might look like this:</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;">&nbsp; &nbsp; $<span style="color:#006600; font-weight:bold;">&#40;</span>document<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #006600;">ready</span><span style="color:#006600; font-weight:bold;">&#40;</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; &nbsp; &nbsp; &nbsp;$<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">".alert-on-click"</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #006600;">bind</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"click"</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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">alert</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"Clicked element "</span> + <span style="color: #000066; font-weight: bold;">this</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; &nbsp; <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; &nbsp; &nbsp;<span style="color:#006600; font-weight:bold;">&#125;</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>This is a rather standard method of binding functions to events with jQuery. It's easy and it's elegant. When the html document has finished loading, the anonymous function is executed. This will find all elements which have the class 'alert-on-click' in the document, and binds a function which is triggered on a click event.</p>
<h2>Slow class selectors</h2>
<p>This method can be problematic with large html documents with thousands of DOM elements. Web browsers which aren't able to do efficient evaluations on class based selectors are seriously disadvantaged here as they need to trawl through the entire document tree to find the elements. Other browsers are better off, but it's still a high cost<br />
operation relative to the super fast id based selector.</p>
<h2>The cost of the bind</h2>
<p>For moment, imagine that you are Crucible as a web application. You've been asked to display a review which has 10,000 lines of code visible. Seems simple - throw each of the lines into a table for easy and nice rendering. Then you need to make sure that whenever the user clicks on lines of code, that they are able to create a comment on that requested line. Simple! Bind an a click event handler to the source lines.</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-37');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-37">
<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;">&nbsp; &nbsp; $<span style="color:#006600; font-weight:bold;">&#40;</span>document<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #006600;">ready</span><span style="color:#006600; font-weight:bold;">&#40;</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; &nbsp; &nbsp; &nbsp;$<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"tr.sourceLine"</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #006600;">bind</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"click"</span>, showCommentBoxFn<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;<span style="color:#006600; font-weight:bold;">&#125;</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>However in this case the browser needs to find 10,000 tr elements, and make 10,000 bind calls. This is noticeably expensive and will slow down the load of the page. Furthermore, it's easy to miss that for memory management reasons, jQuery also <i>unbinds</i> all bound elements on a click away from a page. That means a slow load, but also a slow unload.</p>
<h2>How to count binds</h2>
<p>Here's an easy trick to find out just how many bind and calls you are making when loading your page. Insert this point cut into your JavaScript to add some debugging to jQuery bind events. You'll need <a href="http://www.getfirebug.com/">firebug</a> installed and enabled to see the output.</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-38');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-38">
<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;">jQuery.<span style="color: #006600;">fn</span>.<span style="color: #006600;">bind</span> = <span style="color: #003366; font-weight: bold;">function</span> <span style="color:#006600; font-weight:bold;">&#40;</span>bind<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;<span style="color: #000066; font-weight: bold;">return</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; &nbsp; &nbsp; &nbsp; console.<span style="color: #006600;">count</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"jQuery bind count"</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; &nbsp; console.<span style="color: #006600;">log</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"jQuery bind %o"</span>, <span style="color: #000066; font-weight: bold;">this</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; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> bind.<span style="color: #006600;">apply</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>, arguments<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; <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;">&#125;</span><span style="color:#006600; font-weight:bold;">&#40;</span>jQuery.<span style="color: #006600;">fn</span>.<span style="color: #006600;">bind</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><img alt="Bind Count Annotation" src="http://blogs.atlassian.com/developer/2009/08/03/bind-count-annot.png" height="428" width="1022"/></p>
<p>The team moved away to the not-so-recently jQuery addition, live queries:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-39');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-39">
<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;">&nbsp; &nbsp; $<span style="color:#006600; font-weight:bold;">&#40;</span>document<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #006600;">ready</span><span style="color:#006600; font-weight:bold;">&#40;</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; &nbsp; &nbsp; &nbsp;$<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"tr.sourceLine"</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #006600;">live</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"click"</span>, showCommentBoxFn<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;<span style="color:#006600; font-weight:bold;">&#125;</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>and found a few pitfalls:</p>
<blockquote>
<p>Binding with live events still needs to evaluate the selector expression, which means that $(".class").live() can still be very slow if the DOM is large. We worked around this by loading the large chunks of data with an ajax call after initialising the page view and running our live event binding.</p>
<p>Using live events on mouse events (click, dblclick, mousepress etc) accepts events from the right mouse button when they normally aren't desirable. For example, a right click on a link to copy a gracefully degrading target url would cause the bound event to fire. We solved this by reimplementing jQuery's live function to ignore events caused by right clicks - <span class="mt-enclosure mt-enclosure-file" style="display: inline;"><a href="http://blogs.atlassian.com/developer/2009/08/03/jquery.fecru.overrides.js">see the source</a></span></p>
<p>Quasi race conditions due to the non deterministic execution order of live events. If an element matches more than one live event selector, then the order which in these event functions are executed is not guaranteed. For example:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-40');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-40">
<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;">&#40;</span>document<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #006600;">ready</span><span style="color:#006600; font-weight:bold;">&#40;</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; &nbsp; &nbsp; &nbsp;$<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"div.comment"</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #006600;">live</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"click"</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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; markCommentAsRead<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; &nbsp; &nbsp; &nbsp; &nbsp; <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;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"div.comment a.reply"</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #006600;">live</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"click"</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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; replyToComment<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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// there is no way to prevent a propagation to div.comment</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; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</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;<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>In this case, when the &lt;a class="reply"&gt; link is clicked, both replyToComment() and markCommentAsRead() will be executed.</p>
</blockquote>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/jquery-bondage/feed</wfw:commentRss>
		<slash:comments>47</slash:comments>
		</item>
	</channel>
</rss>
