<?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>markus' blog &#187; JS</title>
	<atom:link href="http://markus.fischer.name/about/archives/category/coding/js/feed/" rel="self" type="application/rss+xml" />
	<link>http://markus.fischer.name/about</link>
	<description>babblings!</description>
	<lastBuildDate>Sun, 26 Apr 2009 20:35:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Javascript parsing: bootleneck?</title>
		<link>http://markus.fischer.name/about/archives/2007/08/17/javascript-parsing-bootleneck/</link>
		<comments>http://markus.fischer.name/about/archives/2007/08/17/javascript-parsing-bootleneck/#comments</comments>
		<pubDate>Fri, 17 Aug 2007 11:44:22 +0000</pubDate>
		<dc:creator>markus</dc:creator>
				<category><![CDATA[JS]]></category>

		<guid isPermaLink="false">http://markus.fischer.name/about/archives/2007/08/17/javascript-parsing-bootleneck/</guid>
		<description><![CDATA[While hacking on performance and a soon to be released customer site, it occurred to me that parsing the JavaScript we use is a pretty huge bottleneck. For CSS and JavaScript we use minification and compression and we even use domain aliases to parallel image/resource downloads. We currently haven&#8217;t the templates connected to the CMS [...]]]></description>
			<content:encoded><![CDATA[<p>While hacking on performance and a soon to be released customer site, it occurred to me that parsing the JavaScript we use is a pretty huge bottleneck. For CSS and JavaScript we use minification and compression and we even use domain aliases to parallel image/resource downloads.</p>
<p>We currently haven&#8217;t the templates connected to the CMS yet, but the raw time is currently between 700 and 900ms. Maybe it can be justified because the layout isn&#8217;t Web 1.0 style (i.e. many round corners, shadows, etc.).</p>
<p>What puzzled me was the &#8220;loading time of JavaScript was around 300ms&#8221;, see this picture:</p>
<p><img src="http://markus.fischer.name/about/wp-content/uploads/2007/08/js-loadandparse2.png" alt="Loading and parsing time of JavaScript" /></p>
<p>That&#8217;s quite a long time. It may is not that good visible from the chart, but nearly everything following the JavaScript is hold until it is read, which delays the complete loading of the rest of the page.</p>
<p>Since behind the scenes the actual request is in reality using <a href="http://code.google.com/p/minify/" target="_blank">Minify</a>, it&#8217;s not just plain serving (but for this scenario the JavaScript has already been cached).</p>
<p>So I took a look just at the JavaScript loading, see this:</p>
<p><img src="http://markus.fischer.name/about/wp-content/uploads/2007/08/js-justload1.png" alt="Just loading, like text." /></p>
<p>What&#8217;s that? Roughly 30ms vs 300ms?</p>
<p>The only realistic guess I&#8217;ve at the moment is: <em>parsing </em>the JavaScript.</p>
<p>This single request loads the following libraries:</p>
<ul>
<li> behaviour</li>
<li>prototype</li>
<li>scriptaculous (+effects)</li>
<li>yui: yahoo-dom-event</li>
<li>yui: container_core</li>
<li>yui: menu.js</li>
<li>our own small JavaScript parts</li>
</ul>
<p>Maybe I&#8217;m too optimistic but it hit me a bit that JavaScript parsing still does take so long. Given that the JavaScript is cached (ideally) things such a huge problem, but still. It was frustrating that I could trim down the &gt;1s request to ~700ms but not further and for most of the part just because it takes as long as it needs it.</p>
]]></content:encoded>
			<wfw:commentRss>http://markus.fischer.name/about/archives/2007/08/17/javascript-parsing-bootleneck/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Behaviour and possible bug in getElementsBySelector</title>
		<link>http://markus.fischer.name/about/archives/2006/10/09/behaviour-and-possible-bug-in-getelementsbyselector/</link>
		<comments>http://markus.fischer.name/about/archives/2006/10/09/behaviour-and-possible-bug-in-getelementsbyselector/#comments</comments>
		<pubDate>Mon, 09 Oct 2006 13:48:17 +0000</pubDate>
		<dc:creator>markus</dc:creator>
				<category><![CDATA[JS]]></category>

		<guid isPermaLink="false">http://markus.fischer.name/about/archives/2006/10/09/behaviour-and-possible-bug-in-getelementsbyselector/</guid>
		<description><![CDATA[Lately I&#8217;ve been banging my head against my keyboard because of a double event assigning bug I expirienced when using Behaviour from Ben Nolan. Tracking done the beast I found that the class pattern matching in Behaviour, which is done through the getElementsBySelector implementation from Simon Willison, uses word boundary matching which I think is [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I&#8217;ve been banging my head against my keyboard because of a <em>double event assigning</em> bug I expirienced when using <a target="_blank" href="http://bennolan.com/behaviour/">Behaviour </a>from Ben Nolan.<br />
Tracking done the beast I found that the class pattern matching in Behaviour, which is done through the <a target="_blank" href="http://simon.incutio.com/archive/2003/03/25/getElementsBySelector">getElementsBySelector </a>implementation from <a target="_blank" href="http://simon.incutio.com/">Simon Willison</a>, uses word boundary matching which I think is not the most suitable solutation for this.</p>
<p>My selector looked like <tt>.menu</tt> and unfortunately it also did match <tt>div class="menu-selector"</tt> in my code. This is because a dash also counts as word boundary when using Javascript <tt>\b</tt> pattern.</p>
<p>I modified the class matching regular expression do the following</p>
<p><tt>'(^|\s)' + className + '($|\s)'</tt></p>
<p>and this did work very well for me.</p>
<p>I&#8217;m currently trying to contact Simon Willison about his opinion whether this change is a good idea or not, I&#8217;ll update this post once I&#8217;ve received feedback.</p>
]]></content:encoded>
			<wfw:commentRss>http://markus.fischer.name/about/archives/2006/10/09/behaviour-and-possible-bug-in-getelementsbyselector/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
