<?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>Uxebu.com - the Ajax and JavaScript Experts &#187; development tools</title>
	<atom:link href="http://uxebu.com/blog/category/development-tools/feed/" rel="self" type="application/rss+xml" />
	<link>http://uxebu.com/blog</link>
	<description>Web, Dojo, news</description>
	<lastBuildDate>Sun, 06 Jun 2010 22:28:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Developing Widgets for Bada Devices</title>
		<link>http://uxebu.com/blog/2010/03/25/developing-widgets-for-bada-devices/</link>
		<comments>http://uxebu.com/blog/2010/03/25/developing-widgets-for-bada-devices/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 11:06:36 +0000</pubDate>
		<dc:creator>Wolfram Kriesing</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Tumbles]]></category>
		<category><![CDATA[development tools]]></category>
		<category><![CDATA[frontend engineering]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[w3c widgets]]></category>
		<category><![CDATA[bada]]></category>
		<category><![CDATA[widgets]]></category>

		<guid isPermaLink="false">http://uxebu.com/blog/2010/03/25/developing-widgets-for-bada-devices/</guid>
		<description><![CDATA[Developing Widgets for Bada Devices
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.badadev.com/developing-widgets-for-bada-devices/">Developing Widgets for Bada Devices</a></p>
]]></content:encoded>
			<wfw:commentRss>http://uxebu.com/blog/2010/03/25/developing-widgets-for-bada-devices/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Make evaled script more useable in Firebug</title>
		<link>http://uxebu.com/blog/2009/11/10/make-evaled-script-more-useable-in-firebug/</link>
		<comments>http://uxebu.com/blog/2009/11/10/make-evaled-script-more-useable-in-firebug/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 08:41:40 +0000</pubDate>
		<dc:creator>Wolfram Kriesing</dc:creator>
				<category><![CDATA[Tumbles]]></category>
		<category><![CDATA[development tools]]></category>
		<category><![CDATA[dojo]]></category>
		<category><![CDATA[frontend engineering]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://blog.uxebu.com/?p=661</guid>
		<description><![CDATA[Make evaled script more useable in Firebug
]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.getfirebug.com/2009/08/11/give-your-eval-a-name-with-sourceurl/">Make evaled script more useable in Firebug</a></p>
]]></content:encoded>
			<wfw:commentRss>http://uxebu.com/blog/2009/11/10/make-evaled-script-more-useable-in-firebug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Git SVN Workflow</title>
		<link>http://uxebu.com/blog/2009/10/21/git-svn-workflow/</link>
		<comments>http://uxebu.com/blog/2009/10/21/git-svn-workflow/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 15:41:43 +0000</pubDate>
		<dc:creator>Wolfram Kriesing</dc:creator>
				<category><![CDATA[Tumbles]]></category>
		<category><![CDATA[development tools]]></category>

		<guid isPermaLink="false">http://blog.uxebu.com/?p=659</guid>
		<description><![CDATA[Git SVN Workflow
]]></description>
			<content:encoded><![CDATA[<p><a href="http://andy.delcambre.com/2008/03/04/git-svn-workflow.html">Git SVN Workflow</a></p>
]]></content:encoded>
			<wfw:commentRss>http://uxebu.com/blog/2009/10/21/git-svn-workflow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dojo D.O.H. Unit Testing</title>
		<link>http://uxebu.com/blog/2009/07/21/dojo-doh-unit-testing/</link>
		<comments>http://uxebu.com/blog/2009/07/21/dojo-doh-unit-testing/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 09:32:38 +0000</pubDate>
		<dc:creator>Wolfram Kriesing</dc:creator>
				<category><![CDATA[Tumbles]]></category>
		<category><![CDATA[development tools]]></category>
		<category><![CDATA[dojo]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://blog.uxebu.com/?p=592</guid>
		<description><![CDATA[Dojo D.O.H. Unit Testing
]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.medryx.org/2008/06/08/dojo-doh-unit-testing/">Dojo D.O.H. Unit Testing</a></p>
]]></content:encoded>
			<wfw:commentRss>http://uxebu.com/blog/2009/07/21/dojo-doh-unit-testing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mobile days in Spain</title>
		<link>http://uxebu.com/blog/2009/05/28/mobile-days-in-spain/</link>
		<comments>http://uxebu.com/blog/2009/05/28/mobile-days-in-spain/#comments</comments>
		<pubDate>Thu, 28 May 2009 11:55:24 +0000</pubDate>
		<dc:creator>Nikolai Onken</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[business]]></category>
		<category><![CDATA[development tools]]></category>
		<category><![CDATA[dojango]]></category>
		<category><![CDATA[dojo]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[uxebu]]></category>
		<category><![CDATA[dojo.beer()]]></category>
		<category><![CDATA[mobile2.0]]></category>

		<guid isPermaLink="false">http://blog.uxebu.com/?p=440</guid>
		<description><![CDATA[As Wolfram already has posted in the last blog post, we are currently involved quite a bit in the mobile world and especially in investigating on how Dojo can be used best to develop for mobile devices.
Taking this as an opportunity we want to announce the next dojo.beer() in Barcelona on June 17th.
You can get [...]]]></description>
			<content:encoded><![CDATA[<p>As Wolfram already has posted in the last <a href="http://blog.uxebu.com/2009/05/27/mobile-weeks-wrap-up/">blog post</a>, we are currently involved quite a bit in the mobile world and especially in investigating on how <a href="http://www.dojotoolkit.org">Dojo</a> can be used best to develop for mobile devices.</p>
<p>Taking this as an opportunity we want to announce the next dojo.beer() in Barcelona on June 17th.<br />
You can get all info about the event on the <a href="http://dojocampus.org/content/2009/05/28/dojobeer-barcelona-june-17th/">DojoCampus event site</a>.</p>
<p>The day after, we are speaking at the <a href="http://mobile20.eu/developer-day/">Mobile2.0 developer day</a> and will give a detailed introduction in how to write mobile applications using the Dojo Toolkit and making sure they are running on different platforms such as <a href="http://phonegap.com/">PhoneGap</a> and the W3C widgets being <a href="http://www.betavine.net">supported by Vodafone</a>.</p>
<p>If you are in Barcelona that week, feel free to get in touch and if you have time to join for drinks during the dojo.beer or the mobile 2.0 conference let us know. Please sign up using the poll below.</p>
<p><strong>Para los españoles :-)</strong></p>
<p>Como Wolfram ha escrito en su último <a href="http://blog.uxebu.com/2009/05/27/mobile-weeks-wrap-up">artículo de blog</a>, nosotros estamos muy involucrados en el mundo de los móviles y estamos especialmente investigando como desarollar de la mejor manera para dispositivos móviles con Dojo.</p>
<p>Aprovechamos esta oportunidad para anunciar el próximo dojo.beer() en Barcelona el 17 de junio de 2009.<br />
Puedes encontrar toda la información en inglés sobre el evento en la <a href="http://dojocampus.org/content/2009/05/28/dojobeer-barcelona-june-17th">página de eventos de DojoCampus</a>.</p>
<p>Al día siguiente vamos a dar una ponencia en el <a href="http://mobile20.eu/developer-day/">Mobile2.0 developer day</a> y vamos a explicar como escribir aplicaciones moviles usando el Dojo Toolit y como asegurarse de que funcionan en múltiples plataformas como <a href="http://phonegap.com">PhoneGap</a> y como W3C Widget  <a href="http://www.betavine.net">apoyado por Vodafone</a> entre otros.</p>
<p>Si estás en Barcelona durante esa semana y te apetece contactar con nosotros  no dudes en venir a tomar una copa  al dojo.beer o a la conferencia mobile2.0. Por favor participa en el poll abajo si quieres ir.</p>
<p><iframe width="300" height="250" frameborder="0" src="http://doodle.com/summary.html?pollId=zw4ui9kraiw8cgt3"> </iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://uxebu.com/blog/2009/05/28/mobile-days-in-spain/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JSONP for Google spreadsheets</title>
		<link>http://uxebu.com/blog/2009/04/30/jsonp-for-google-spreadsheets/</link>
		<comments>http://uxebu.com/blog/2009/04/30/jsonp-for-google-spreadsheets/#comments</comments>
		<pubDate>Thu, 30 Apr 2009 11:33:20 +0000</pubDate>
		<dc:creator>Wolfram Kriesing</dc:creator>
				<category><![CDATA[development tools]]></category>
		<category><![CDATA[dojo]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[uxebu]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[jsonp]]></category>
		<category><![CDATA[mashup]]></category>
		<category><![CDATA[spreadsheet]]></category>

		<guid isPermaLink="false">http://blog.uxebu.com/?p=343</guid>
		<description><![CDATA[Nikolai said yesterday &#8220;Is Google spreadsheet becoming the new Microsoft Access?&#8221;. You know the visual database and form designer. Well, for the web and pure mashup apps, that are mainly or completely based on the web&#8217;s infrastructure, so to say cloud services, one could answer &#8220;Yes, it can cover at least the database part&#8221;. It [...]]]></description>
			<content:encoded><![CDATA[<p>Nikolai said yesterday &#8220;Is Google spreadsheet becoming the new Microsoft Access?&#8221;. You know the visual database and form designer. Well, for the web and pure mashup apps, that are mainly or completely based on the web&#8217;s infrastructure, so to say cloud services, one could answer &#8220;Yes, it can cover at least the database part&#8221;. It may be poor in features, but a nice start.<br />
Well all this buzzy stuff aside, read on to see how to use JSONP with a Google spreadsheet, even though it&#8217;s not exactly provided.<br />
<span id="more-343"></span></p>
<p>For me as a front end engineer and JavaScript lover I always think twice before I set up a server system with a database and some Python or PHP code in between which then provides me with the data I need. This is painful, actually too much work for a lazy front-end dev  like me, I would also have to do the permission handling and let alone the maintenance. Of course there are projects where it is not possible to store everything in the cloud, as what would be the solution I would favor over the before mentioned server infrastructure. (Let me just get this straight: by storing in the cloud I mean storing my data on mashable online services, which I can access via JavaScript, you will see in a second.)<br />
Ideally JSONP is the solution of choice for getting the data, but sometimes there is not this choice and you have to look around for other ways.</p>
<h2>Why JSONP?</h2>
<p>The easiest and probably most relevant reason why to use JSONP (<a href="http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/">read here how it started</a>), is that it is native JavaScript. There is no mapping from one format to another required, so you get natural performance. Second it is just a simple technique for cross-domain communication. And you don&#8217;t have to setup no complicated event handling for getting informed about when the data are loaded, it&#8217;s all handled. </p>
<h2>Google spreadsheet</h2>
<p>Let&#8217;s take <a href="http://spreadsheets.google.com/pub?key=rai4OXpsbS2Bc04lWn575ZA">this tiny spreadsheet</a>, it contains the data I want to request, e.g. for showing on the uxebu.com website.<br />
<iframe width='95%' height='200' frameborder='0' style="margin:1em 0; border:1px outset grey;" src='http://spreadsheets.google.com/pub?key=rai4OXpsbS2Bc04lWn575ZA&#038;output=html&#038;widget=true'></iframe><br />
This spreadsheet is really easy to maintain, no geek knowledge is required for that, and this is the great thing about it. If that can serve as the data source for a web service or widget it just makes maintenance so much easier, and you can also tell your customer &#8220;just change the data as you like&#8221;. It&#8217;s not only, that changing is easy, also the permission handling is just a couple of clicks away. The data are hosted on one of the best working networks and you can be pretty sure that if you have no high-traffic site, that those data will just always be served at awesome speed. Enough reasons? I think so.</p>
<h2>How to get the data</h2>
<p>The <a href="http://code.google.com/apis/spreadsheets/docs/2.0/reference.html">google docs</a> unfortunately show nothing really nice about JSONP. Yes you can make the ATOM feed of the spreadsheet be <a href="http://spreadsheets.google.com/feeds/list/rai4OXpsbS2Bc04lWn575ZA/default/public/basic?alt=json-in-script">served as JSONP</a>, but look at the data format (better don&#8217;t :-)), it really is not what you expect when working with JSON. The data are linear in there, so you have to apply the logic that actually the spreadsheet has in it again to reformat the data, and may be convert and take them apart again. Just believe me it&#8217;s not what one expects. If you like the pain, try it out.<br />
And there is the CSV export of the data, that I always loved for it&#8217;s simplicity. Just add <code>&amp;output=csv</code> to the URL and you get your <a href="http://spreadsheets.google.com/ccc?key=rai4OXpsbS2Bc04lWn575ZA&#038;output=csv">spreadsheet as CSV</a>. Very nice. Unfortunately trying to load those data using <code>dojo.io.script.get</code> of course fails:<br />
<div id="attachment_362" class="wp-caption alignleft" style="width: 619px"><a href="http://blog.uxebu.com/wp-content/uploads//2009/04/csv-load-fail.jpg"><img src="http://blog.uxebu.com/wp-content/uploads//2009/04/csv-load-fail.jpg" alt="CSV loading fails" title="csv-load-fail" width="609" height="169" class="size-full wp-image-362" /></a><p class="wp-caption-text">CSV loading fails</p></div><br />
Well, trying doesn&#8217;t cost a dime. Of course, I tried this first, though it was clear that it wouldn&#8217;t work.<br />
I didn&#8217;t want to give up on this nice format, it has all the goodies, the lines, columns of the spreadsheet, no overhead, easily human-readable (which is always nice for finding errors in the parsing process) and it just maps so well to JSON. That&#8217;s the clue, it maps to JSON, now I just need to get that done. And since I didn&#8217;t want to add the overhead of passing the data through a Yahoo! Pipe just for getting a JSONP format I thought, why not make the CSV look like JSONP. The two formats are close enough.</p>
<h2>JSONPed CSV</h2>
<p>After trying a little bit and seeing the result that google spit out and fixing it again I had the solution (<a href="http://spreadsheets.google.com/pub?key=rmlQvp80ksEJg6r49fJhjuw&#038;output=csv">the spreadsheet below</a>), pretty easy actually.<br />
<iframe width='95%' height='200' frameborder='0' style="margin:1em 0; border:1px outset grey;" src='http://spreadsheets.google.com/pub?key=rmlQvp80ksEJg6r49fJhjuw&#038;output=html&#038;widget=true'></iframe><br />
The CSV format is already comma separated, that is kind of half the way to JSON. At least the comma will make sure that we can distinguish the columns from one another. I ended up adding the callback name to the first cell on the left like this <code>__callbackFunctionName__('</code> the opening parentheses and the apostrophe starts the function call that will be made inside the script tag you load it into. Now you can already guess that either every cell is surrounded by apostrophes, but that would just be too much hazzle and too error-prone, so I decided to just add a column before and one behind the data, when parsing the CSV those will just be dismissed, since they won&#8217;t contain a headline, therefore have no key to map the data to.<br />
The last line is a little special, it contains the extra cell containing <code>0);</code> which is closing the function, this is actually only there to create an extra column, where each line has just a space in it, so we get the comma at the end of every line. So that in the end our <a href="http://spreadsheets.google.com/pub?key=rmlQvp80ksEJg6r49fJhjuw&#038;output=csv">JSONPed CSV</a> (the <a href="http://spreadsheets.google.com/pub?key=rmlQvp80ksEJg6r49fJhjuw">human-readable version here</a>) looks just like this:<br />
<code><br />
__cfn__(',name,url,status,irc, ',<br />
 ',dojango,http://dojango.org,released,http://mibbit.com/chat/?server=irc.freenode.net&#038;channel=%23dojango, ',<br />
 ',dojodocs,http://dojodocs.uxebu.com,preview,, ',<br />
 ',dools,http://code.google.com/p/dools,in progress,, ',<br />
 ',xray,http://code.google.com/p/xray-project/,alpha,http://mibbit.com/chat/?server=irc.freenode.net&#038;channel=%23xray, ',<br />
 ',d.js,http://code.google.com/p/ddotjs/,unreleased,, ',0);<br />
</code></p>
<h2>The client</h2>
<p>Every line is now a parameter for our callback function. Simply use dojo&#8217;s <code>dojo.io.script.get()</code> hook onto the callback function and we got our spreadsheet data in any site within JavaScript. A little after-parsing and done.<br />
The dojo source code may look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">dojo.<span style="color: #660066;">require</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;dojo.io.script&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
dojo.<span style="color: #660066;">addOnLoad</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> url <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;http://spreadsheets.google.com/pub?key=rmlQvp80ksEJg6r49fJhjuw&amp;output=csv&quot;</span><span style="color: #339933;">;</span>
    dojo.<span style="color: #660066;">io</span>.<span style="color: #660066;">script</span>.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>url<span style="color: #339933;">:</span>url<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    dojo.<span style="color: #660066;">connect</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;__cfn__&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> args <span style="color: #339933;">=</span> dojo._toArray<span style="color: #009900;">&#40;</span>arguments<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            colNames <span style="color: #339933;">=</span> args<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;,&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slice</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            data <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> l<span style="color: #339933;">=</span>args.<span style="color: #660066;">length</span><span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> d<span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>l<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #006600; font-style: italic;">// Convert the data using the colNames to an object.</span>
            <span style="color: #006600; font-style: italic;">// (Might be an esoteric step, but correct this way.)</span>
            d <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
            dojo.<span style="color: #660066;">forEach</span><span style="color: #009900;">&#40;</span>args<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;,&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slice</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #339933;">,</span> index<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                <span style="color: #006600; font-style: italic;">// Do some CSV conversion.</span>
                <span style="color: #000066; font-weight: bold;">item</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\&quot;\&quot;/g</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'&quot;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #3366CC;">'&quot;'</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">length</span><span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #3366CC;">'&quot;'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                    <span style="color: #000066; font-weight: bold;">item</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">length</span><span style="color: #339933;">-</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                d<span style="color: #009900;">&#91;</span>colNames<span style="color: #009900;">&#91;</span>index<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">item</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            data.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span>d<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        dojo.<span style="color: #660066;">query</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.theProjects&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> dojo.<span style="color: #660066;">toJson</span><span style="color: #009900;">&#40;</span>data<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>You can <a href="http://static.uxebu.com/~cain/JSONPedCSV.html">download and try out a test page here</a>.</p>
<p>Of course, there are a couple of drawbacks.</p>
<ol>
<li>
You have to make the spreadsheet adhere to a certain style, the first column, the last column, etc. and one error in there may break it entirely. So there is not much fault tolerance. Additionally you are not supposed to use new lines in the content of the spreadsheet!
</li>
<li>The callback name is fix, though if you are using this sheet in one app this should be ok.
</li>
</ol>
<p>But see the advantages, you get permission handling for editors for free, you can let your customer edit the data without your involvement and so on. As always, when the use case requires this solution you can pull it out of your sleeve.<br />
Oh, the source code above is also still not handling the escaped commas I guess, so there are still places where this can be improved.</p>
<h2>Further thinking</h2>
<p>Another way I though about was simply only surrounding the CSV by /* and */ which would relieve us from any JavaScript parsing error, since everything is a comment. But my quick test using innerHTML didn&#8217;t work. And innerHTML is not that relieable anyway so it might be better I didn&#8217;t waste more time on it. May be loading this into CSS tag enables us reading the data back &#8230; I don&#8217;t know, those are just random thoughts.<br />
Another thought Nikolai had was &#8220;A spreadsheet-based CMS&#8221;. Of course, why not. You can basically store any kind of data in the spreadsheet, even HTML if you really would want to.</p>
<p>This can spin of more discussions and interesting ideas, let&#8217;s see what the future will bring.<br />
The web is becoming more fun every day!</p>
]]></content:encoded>
			<wfw:commentRss>http://uxebu.com/blog/2009/04/30/jsonp-for-google-spreadsheets/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Some for-loop considerations</title>
		<link>http://uxebu.com/blog/2009/03/26/some-for-loop-considerations/</link>
		<comments>http://uxebu.com/blog/2009/03/26/some-for-loop-considerations/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 14:49:16 +0000</pubDate>
		<dc:creator>Wolfram Kriesing</dc:creator>
				<category><![CDATA[development tools]]></category>
		<category><![CDATA[dojo]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[uxebu]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[coding style]]></category>
		<category><![CDATA[for-loop]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://blog.uxebu.com/?p=142</guid>
		<description><![CDATA[We have been developing some coding style guide lines to produce better code and make our code easier maintainable and portable. Also thinking about code inspection tools and continuous integration techniques which analyze the code will profit from a well defined and verifyable style.
While discussing a rather simple rule I thought this might be interesting [...]]]></description>
			<content:encoded><![CDATA[<p>We have been developing some coding style guide lines to produce better code and make our code easier maintainable and portable. Also thinking about code inspection tools and continuous integration techniques which analyze the code will profit from a well defined and verifyable style.<br />
While discussing a rather simple rule I thought this might be interesting to delve into a bit. You will be surprised how much you can discuss about a simple thing such as a for-loop and that is not only true for JavaScript, I am sure.<br />
<span id="more-142"></span></p>
<p>Well, call me pedantic for even discussing this and seeing this as relevant. But everybody knows that adhering coding styles make programming in a team way more pleasant and it is just way more efficient to just code and not to style! Which includes not having to think about how to style the code, though I realize that a lot of programmers have a problem adapting to coding styles.<br />
We at uxebu basically defined that we are applying the coding guide lines of the project that we possibly contribute stuff back to. This means our JavaScript code applies the <a href="http://www.dojotoolkit.org/developer/StyleGuide">dojo coding style guide</a> and our python stuff (we use internally) applies the <a href="http://docs.djangoproject.com/en/dev/internals/contributing/#coding-style">django coding style guide</a>.</p>
<p>But let&#8217;s look at the for-loop now.</p>
<h2>The default</h2>
<p>The most common usage of a for loop is the following.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>nodes.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> node <span style="color: #339933;">=</span> nodes<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">// whatever</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Nothing spectacular here. But let&#8217;s take it apart a bit. There are two things that are commonly known that can be optimized.</p>
<ol>
<li>The comparison &#8220;i&lt;nodes.length&#8221; in line 1 evaluates the length of nodes on every iteration, if the nodes array is not modified while looping over it or the change to it is not relevant, this can be optimized.</li>
<li>Also the declaration of the variable &#8220;node&#8221; in line 2 is done multiple times, so this is just a small unnecessary thing to do.</li>
</ol>
<p>So let&#8217;s optimize the things we just found out.</p>
<h2>Version 2</h2>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> node<span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> len<span style="color: #339933;">=</span>nodes.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>len<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    node <span style="color: #339933;">=</span> nodes<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">// whatever</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Another step on our way was to optimize the variable declarations and reducing their count from three down to one. In some code you can then see the following.</p>
<h2>Version 3</h2>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> node<span style="color: #339933;">,</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> len<span style="color: #339933;">=</span>nodes.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>len<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    node <span style="color: #339933;">=</span> nodes<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">// whatever</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Actually we have already skipped a tiny step in between, very often you can see multiple var-statements as opposed to the already &#8220;squeezed&#8221; one-liner in line 1 above. The way of writing it as seen here, is reasonable if there are a couple other variables to be declared, you just need one var-statement. This will basically reduce the code size, if your minifier doesn&#8217;t already do that for you. <a href="http://wonko.com/post/try-to-use-one-var-statement-per-scope-in-javascript#comment-4819">As stated here</a> it seems to be specified to be irrelevant to performance. So event the argument under 2. against the first version (see above) is not very strong.<br />
Just a small side-note: the one line var-statement evaluates in declaration order, so something like this will work!</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> arr <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span><span style="color: #CC0000;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> len <span style="color: #339933;">=</span> arr.<span style="color: #660066;">length</span><span style="color: #339933;">,</span> x <span style="color: #339933;">=</span> len<span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">;</span></pre></div></div>

<p>The &#8220;len&#8221; and also &#8220;x&#8221; variables contain the proper content as you are expecting. The comma-separated var-statement evaluates the assignment expression by expression and steps on to the next assignment. Therefore &#8220;len&#8221; and &#8220;x&#8221; will have the proper values 3 and 2.<br />
But let&#8217;s go back to our for-loop.</p>
<h2>Version 4</h2>
<p>If the var-statement is outside the for-loop and especially if other variables (outside of the scope of the for-loop) are declared there the source code get&#8217;s blury and harder to read. For example:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> someVar <span style="color: #339933;">=</span> whatever<span style="color: #339933;">,</span> anotherVar <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">4</span><span style="color: #339933;">,</span><span style="color: #CC0000;">5</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> node<span style="color: #339933;">,</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> len<span style="color: #339933;">=</span>nodes.<span style="color: #660066;">length</span><span style="color: #339933;">;</span></pre></div></div>

<p>The first two variable declarations (someVar and anotherVar) have nothing to do with the for-loop context, but the others do, so this blurs the source code and is prone to errors. Also if you separate this source code onto multiple lines like so:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> someVar <span style="color: #339933;">=</span> whatever<span style="color: #339933;">,</span> anotherVar <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">4</span><span style="color: #339933;">,</span><span style="color: #CC0000;">5</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
    node<span style="color: #339933;">,</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> len<span style="color: #339933;">=</span>nodes.<span style="color: #660066;">length</span><span style="color: #339933;">;</span></pre></div></div>

<p>it is still a possible point of failure. I for example, forgot the comma on line 1 which made this source code</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> someVar <span style="color: #339933;">=</span> whatever<span style="color: #339933;">,</span> anotherVar <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">4</span><span style="color: #339933;">,</span><span style="color: #CC0000;">5</span><span style="color: #009900;">&#93;</span>
    node<span style="color: #339933;">,</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> len<span style="color: #339933;">=</span>nodes.<span style="color: #660066;">length</span><span style="color: #339933;">;</span></pre></div></div>

<p>still work. But and this is a <strong>big but</strong>, the code get&#8217;s a different meaning now! First, line 1 will work, since the semicolon at the end of the line is not mandatory. And second (if not declared inside this scope before) the variables on line 2 are now defined in global scope. And that can really cause a hard to find bug!<br />
Another good reason for not doing this, is that extending the code may lead to developers adding code in between the var-declaration and the for-loop, for whatever reason. Then the variable declarations for the for-loop &#8220;drift away&#8221; and loose their context even a bit more. And the source code becomes harder to understand.</p>
<p>So we rather put all the variable declarations into the for-loop&#8217;s var-statement. Like so:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> someVar <span style="color: #339933;">=</span> whatever<span style="color: #339933;">,</span> anotherVar <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">4</span><span style="color: #339933;">,</span><span style="color: #CC0000;">5</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// This is outside the for-loop and also looks like it.</span>
<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> len<span style="color: #339933;">=</span>nodes.<span style="color: #660066;">length</span><span style="color: #339933;">,</span> node<span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>len<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    node <span style="color: #339933;">=</span> nodes<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">// whatever</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Now we have a pretty compact and well context-focused syntax for declaring variables needed within a for-loop. This code is nicely readable and has no impact on performance, even if in most cases good and maintainable code is worth more than the fastest code, but that&#8217;s a use case based decision! We are taking this as a standard for uxebu code.</p>
<p>What do you think? Let us know if you see potential for optimization.</p>
]]></content:encoded>
			<wfw:commentRss>http://uxebu.com/blog/2009/03/26/some-for-loop-considerations/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Pure Client-side Dojo API Docs</title>
		<link>http://uxebu.com/blog/2009/03/12/pure-client-side-dojo-api-docs/</link>
		<comments>http://uxebu.com/blog/2009/03/12/pure-client-side-dojo-api-docs/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 20:43:26 +0000</pubDate>
		<dc:creator>Wolfram Kriesing</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[development tools]]></category>
		<category><![CDATA[dojo]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[uxebu]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[documentation]]></category>

		<guid isPermaLink="false">http://blog.uxebu.com/?p=125</guid>
		<description><![CDATA[It was a project last year, where yet another inline documentation syntax was &#8220;created&#8221; and suggested to be used. That triggered our brains and they started spinning caused by the unhappiness of reinventing the wheel, especially for something that is still too much of a step-child for frontend engineers and doesn&#8217;t get the necessary dedication [...]]]></description>
			<content:encoded><![CDATA[<p>It was a project last year, where yet another inline documentation syntax was &#8220;created&#8221; and suggested to be used. That triggered our brains and they started spinning caused by the unhappiness of reinventing the wheel, especially for something that is still too much of a step-child for frontend engineers and doesn&#8217;t get the necessary dedication anyway, the JavaScript inline docs. So let&#8217;s give them some love :-).</p>
<p>Fast forwarding &#8230; what came out of it is the <a href="http://dojodocs.uxebu.com" target="_blank">API docs viewer</a> which, we here at uxebu, built over the christmas holidays. It is completely client-based, for creating the documentation and retreiving all the information, no server-side code is needed anymore, it&#8217;s all done in <a href="http://dojotoolkit.org" target="_blank">dojo</a>.<br />
<span id="more-125"></span></p>
<p>If you want to see a detailed introductional video, sit back, relax and enjoy the following screencast:</p>
<p><center><br />
<object width="600" height="375"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=3600935&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=3600935&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="600" height="375"></embed></object><br /><a href="http://vimeo.com/3600935">JavaScript API Docs preview video</a> from <a href="http://vimeo.com/uxebu">uxebu</a> on <a href="http://vimeo.com">Vimeo</a>.<br />
</center></p>
<p style="margin-top: 30px;"><center><a href="http://dojodocs.uxebu.com/" target="_blank"><img src="http://blog.uxebu.com/wp-content/uploads//2009/03/apidocslaunch.gif" /></a></center></p>
<h2>Inline doc styles</h2>
<p>There are a couple of JavaScript inline documentation tools and styles out there, but no real standard has evolved yet. Maybe because of JavaScript&#8217;s dynamic nature it&#8217;s hard to fix it to just one style. Though this just makes the task more interesting, actually. </p>
<p>Let&#8217;s take a step back and take a look at just three of the various different inline doc styles.</p>
<p>The <em>jQuery way</em>, pretty much textual.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Execute a callback for every element in the matched set.</span>
<span style="color: #006600; font-style: italic;">// (You can seed the arguments with an array of args, but this is</span>
<span style="color: #006600; font-style: italic;">// only used internally.)</span>
each<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span> callback<span style="color: #339933;">,</span> args <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></pre></div></div>

<p>The <em>YUI way</em>, as you will see it&#8217;s very JavaDoc like, the method is documented above the actual definition and uses the @ sign for identifiers.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">/**
 * Returns a string without any leading or trailing whitespace.  If 
 * the input is not a string, the input will be returned untouched.
 * @method trim
 * @since 2.3.0
 * @param s {string} the string to trim
 * @return {string} the trimmed string
 */</span>
trim<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></pre></div></div>

<p>The <em>dojo way</em>, with proprietary identifiers, inside the function code!</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">dojo.<span style="color: #660066;">trim</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>str<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #006600; font-style: italic;">//	summary:</span>
	<span style="color: #006600; font-style: italic;">//		Trims whitespace from both sides of the string</span>
	<span style="color: #006600; font-style: italic;">//	str: String</span>
	<span style="color: #006600; font-style: italic;">//		String to be trimmed</span>
	<span style="color: #006600; font-style: italic;">//	returns: String</span>
	<span style="color: #006600; font-style: italic;">//		Returns the trimmed string</span>
	<span style="color: #006600; font-style: italic;">//	description:</span>
	<span style="color: #006600; font-style: italic;">//		This version of trim() was selected for inclusion into the base due ...</span></pre></div></div>

<p>We see that there are different levels of depth and explicitness in the inline comments. But they all have in common, that important and interesting information are contained inside the source code, that should be exposed to the users of those APIs.</p>
<h2>The __doc__ approach</h2>
<p>In python, a certain type of comments is available as the docstring property __doc__ of the function it is in. This was actually the initial idea, to provide the docs in this kind of way:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">dojo.<span style="color: #660066;">trim</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>str<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
dojo.<span style="color: #660066;">trim</span>.__doc__ <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
    summary<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;Trims whitespace from both sides of the string&quot;</span><span style="color: #339933;">,</span>
    returns<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>type<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;String&quot;</span><span style="color: #339933;">,</span> summary<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;Returns the trimmed string&quot;</span><span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>It&#8217;s is pretty obvious, that this is is pretty ugly source code in the first place and secondly a comment is not a comment anymore but becomes source code. Prone to errors, and not really leading to higher productivity, we realized that this approach was actually just a learning stage.<br />
Still it is pretty handy to use the command line in FireBug and have the docs at hand via autocompletion e.g. just typing <em>dojo.trim.__doc__</em> and the docs are there (this feature is currently also implemented, but the __doc__ property must be generated by a function call afterwards and it is not in the main focus for the current state of the project).</p>
<h2>The less disruptive approach</h2>
<p>Since the __doc__ approach has the ugly side effect that library authors would have to change all their source code it was dismissed pretty quickly. New ways had to be explored. Driven by the flexibility of JavaScript and it&#8217;s dynamic nature we found a nice mix of reflection and minimal file parsing that allows us to extract the information from the existing raw (unpacked and not minified!) source code, without the need to modify it upfront.</p>
<p>First comes <strong>the reflection</strong>. Using the simple for-in loop over the prototype and the object itself allows us to extract all the methods and properties. Applying a little bit of logic using toString() and alikes and we know if the implementation of this object overrides, inherites or creates this method, we find out the default value of properties and a lot more. In the special case of dojo we can also easily find out the parent class(es). The reflection is actually worth a separate article, since it is quite powerful and allows deep insights into a class&#8217;s inner values.</p>
<p>Second step is <strong>simple file parsing</strong>. Since we know that object &#8220;foo&#8221; has the method &#8220;bar&#8221;, we know that in the source code we can find the definition by looking for the following patterns:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">foo.<span style="color: #660066;">bar</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
<span style="color: #006600; font-style: italic;">// OR</span>
foo <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
    bar<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #006600; font-style: italic;">// OR</span>
foo <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">bar</span> <span style="color: #339933;">=</span>  <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>There are a couple of special but rare other cases, but the patterns are very simple to detect as you can see. So our FileParser doesn&#8217;t really need to understand the JavaScript syntax, it is just looking for exact patterns and is therefore quite fast (we can surely still improve on the performance!).<br />
Using regular expressions we also find out the parameters and the actual docstring itself, which then is parsed by the DocStringParser.</p>
<p>Let&#8217;s summarize. We have an object&#8217;s/class&#8217;s (if you want to call it a class) methods, properties, their according docstring and the docstrings of the class itself. We know the inheritance structure, can determine the type (public, private, etc.) from the name (for now we assume it is private when it starts with an &#8220;_&#8221;) or soon we will use the docstring identifier &#8220;tags&#8221; (which was just shortly introduced into dojo as <a href="http://bugs.dojotoolkit.org/browser/dijit/trunk/_Widget.js?rev=16933#L301">you can see it used here</a>). And we have example code, which is contained in a lot of docstrings. So this is already quite an amount of useful data. Let&#8217;s make them useable.</p>
<h2>Plugging it all together</h2>
<p>The pieces are there, they just need to be plugged together and hopefully a useful API docs viewer will arise. For this special dojo use case, we also had to build a mapper which enables the mapping of a namespace to the correct file(s). E.g. dojo.query() is actually a function inside the <em>dojo</em> object, which would naturally mean it is inside <em>dojo.js</em>, but in this case this method is in a separate file <em>query.js</em> which is &#8220;the knowledge&#8221; of the mapper.</p>
<p>Building the namespace tree was another challenge, loading all the files in the browser and inspecting the entire namespace via JavaScript would just be an aweful waste of resources. So currently there is a small python script which generates the JSON files which contain the contents of the tree to the left. But the high flexibility of using dynamic extending of objects (like e.g. <a href="http://bugs.dojotoolkit.org/browser/dojo/trunk/NodeList-fx.js?rev=12797#L10">NodeList-fx does</a>) mixins and other things make it hard to rely purely on the generated contents of the tree, so they are partly hand-crafted too.</p>
<p><a href='http://blog.uxebu.com/wp-content/uploads/2009/03/dojo-ui.jpg' style="float:right; padding:5px"><img src="http://blog.uxebu.com/wp-content/uploads/2009/03/dojo-ui.jpg" alt="dojo UI example" title="dojo-ui" width="192" height="49" class="size-full wp-image-127" /></a>The UI is purely dojo, showing off some of the neat features, like the slick ExpandoPane. In my eyes it looks very nice, with a lot of attention to the detail. The UI was actually the part that needed the least time to build, thanks to Nikolai&#8217;s deep knowledge it was a piece of cake. There are of course a couple of glitches like the wrapping of the tabs, but hopefully this is just another kick in the right direction to speed up those kind of fixes. Because what is there is already much more than just the base of a GUI toolkit with some widgets, it is a full-fledged-ready-to-go-batteries-included-kick-ass set of UI components. (Ok, enough wallowing, yes I am biased :-).) So look for yourself and let us know what you think.</p>
<h2>The future</h2>
<p>As you know it too, working on those kind of projects always spins off a lot of new ideas. So we want to share some with you and maybe even get some help on some of them. First: we will put the source code out on google code (or alike) and it will be open for contributions, of course. We just need to do some renaming to ensure future-proof enhancements won&#8217;t just clobber this thing and make it unmaintainable.</p>
<p>Another idea is to configure the API docs viewer for custom namespaces and as long as the inline comments are dojo style it should be just a snap of a finger to get your own project&#8217;s API docs out. Well, actually the snap of a finger is the creation of the above mentioned JSON file, which contains the tree structure. But one day we will also have an auto-detector which builds the tree initially out of traversing through a given existing namespace (given that it is entirely loaded).</p>
<p>Idea No. 734 :-) was to provide the API viewer for other libraries too. The architecture is made this way, that the reflection and file parsing are separated and could be extended to work with another inline doc style syntax (we made first experiments with it). In order to do this right we think about having a common interface where to put and get the apidoc data from. A json-schema for API doc data is required. I have started on one, but this task really is huge when done right.</p>
<p>Of course the __doc__ property will be provided. Currently when working with libraries or function that I don&#8217;t know I mostly use toString() on it and learn from the source code. I could also very well imagine myself using __doc__ if it was there. So keep looking for that, I think it can change the way one uses the FireBug console and learns about libraries.</p>
<p>Since we know all the objects, methods on the one hand and the according docs on the other hand we can tell how good the doc coverage is. This heads into the direction of continuous integration and imho that is really where JavaScript still has a long way to go.</p>
<p>And there are a couple more ideas, like running the inline doctests in the UI, integrating the API viewer with Bespin and allowing to throw the api viewer onto any page using a bookmarklet, which would nicely let you browse the JavaScript API of any site, no matter if you want to learn, fix something or whatever. To mention just some of the ideas &#8230;</p>
<p>Now if you want to get your hands dirty and play with the code, see how it can integrate with your own code or just have offline dojo api documentation, drop us an email ( labs (a t) uxebu.com ) and we will make sure a copy of the code lands in your mailbox. Also, if you find bugs, have ideas, want to contribute, contact us and we will exchange ideas to make this tool the best available javascript api viewer out there.</p>
]]></content:encoded>
			<wfw:commentRss>http://uxebu.com/blog/2009/03/12/pure-client-side-dojo-api-docs/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
		<item>
		<title>Firefox on OSX with dtrace &#8211; Part II</title>
		<link>http://uxebu.com/blog/2009/03/02/firefox-on-osx-with-dtrace-part-ii/</link>
		<comments>http://uxebu.com/blog/2009/03/02/firefox-on-osx-with-dtrace-part-ii/#comments</comments>
		<pubDate>Mon, 02 Mar 2009 11:00:23 +0000</pubDate>
		<dc:creator>Nikolai Onken</dc:creator>
				<category><![CDATA[development tools]]></category>
		<category><![CDATA[dojo]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[dtrace]]></category>
		<category><![CDATA[profiling]]></category>

		<guid isPermaLink="false">http://blog.uxebu.com/?p=123</guid>
		<description><![CDATA[In the last article I have given an introduction on how to get dtrace running in your development environment, how to compile firefox and how a simple dtrace script looks like.
Today we will take a look at how to write more useful dtrace scripts and I will show how to analyze the resulting data in [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://blog.uxebu.com/2009/02/20/firefox-on-osx-with-dtrace/">the last article</a> I have given an introduction on how to get dtrace running in your development environment, how to compile firefox and how a simple dtrace script looks like.<br />
Today we will take a look at how to write more useful dtrace scripts and I will show how to analyze the resulting data in a simple dojox.charting chart.</p>
<p><span id="more-123"></span></p>
<p>Dtrace is a very powerful tool to take a deep and exact look into your systems internals. For us webdevelopers it is a great tool if want to investigate performance issues or bottlenecks within the browser.</p>
<h2>A few dtrace details</h2>
<p>Dtrace works by using probes provided by so called &#8220;providers&#8221; which are scattered throughout your system and also in important places in firefox. When starting a dtrace session those probes get activated and you can handle the information given by the probes.</p>
<p>Besides that, dtrace&#8217;s internal language D gives you many options of handling the data, making aggregations, predicative constructs and other features to give you a good view of what is happening.</p>
<h2>Probe activation</h2>
<p>To activate a dtrace probe first of all you need to know what probes are available on your system, in our case which probes are available through firefox. A simple</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$ dtrace <span style="color: #339933;">-</span>l <span style="color: #339933;">|</span> grep <span style="color: #339933;">-</span>i <span style="color: #3366CC;">&quot;javascript&quot;</span></pre></div></div>

<p>should return a list of available probes looking like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #CC0000;">24728</span> javascript13762    libmozjs.<span style="color: #660066;">dylib</span>                        js_Execute execute<span style="color: #339933;">-</span>done
<span style="color: #CC0000;">24729</span> javascript13762    libmozjs.<span style="color: #660066;">dylib</span>             jsdtrace_execute_done execute<span style="color: #339933;">-</span>done
<span style="color: #CC0000;">24730</span> javascript13762    libmozjs.<span style="color: #660066;">dylib</span>                        js_Execute execute<span style="color: #339933;">-</span>start
<span style="color: #CC0000;">24731</span> javascript13762    libmozjs.<span style="color: #660066;">dylib</span>            jsdtrace_execute_start execute<span style="color: #339933;">-</span>start
<span style="color: #CC0000;">24732</span> javascript13762    libmozjs.<span style="color: #660066;">dylib</span>                      js_Interpret function<span style="color: #339933;">-</span>args
<span style="color: #CC0000;">24733</span> javascript13762    libmozjs.<span style="color: #660066;">dylib</span>            jsdtrace_function_args function<span style="color: #339933;">-</span>args
<span style="color: #CC0000;">24734</span> javascript13762    libmozjs.<span style="color: #660066;">dylib</span>                      js_Interpret function<span style="color: #339933;">-</span>entry
<span style="color: #CC0000;">24735</span> javascript13762    libmozjs.<span style="color: #660066;">dylib</span>           jsdtrace_function_entry function<span style="color: #339933;">-</span>entry
...</pre></div></div>

<p>The first column is the probe ID, the second the name of the probe provider, the third the location of the probe, the fourth the name of the program function the probe is located at, and the last is the probe name.<br />
Now when you want to activate a probe you use following schema:</p>

<div class="wp_syntax"><div class="code"><pre class="javascirpt" style="font-family:monospace;">provider:module:function:name</pre></div></div>

<p>So to activate the &#8220;function-entry&#8221; probe we can write</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">javascript13762<span style="color: #339933;">:</span>libmozjs.<span style="color: #660066;">dylib</span><span style="color: #339933;">:</span>jsdtrace_function_entry<span style="color: #339933;">:</span>function<span style="color: #339933;">-</span>entry</pre></div></div>

<p>This is long to write, especially in our case since we would want to activate all function-entry probes. Se we can shorten this to</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">javascript<span style="color: #339933;">*:::</span>function<span style="color: #339933;">-</span>entry</pre></div></div>

<h2>A simple dtrace script</h2>
<p>Now that we know how to activate a probe lets take a look at the dtrace script I was showing in the <a href="http://blog.uxebu.com/2009/02/20/firefox-on-osx-with-dtrace/">last blogpost</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">sudo dtrace <span style="color: #339933;">-</span>n javascript<span style="color: #339933;">*:::</span>function<span style="color: #339933;">-</span>entry<span style="color: #3366CC;">'{ @[copyinstr(arg1), copyinstr(arg2)] = count(); }'</span> 
    <span style="color: #339933;">-</span>n END<span style="color: #3366CC;">'{ printa(&quot;<span style="color: #000099; font-weight: bold;">\n</span>%-6s %-35s  %5@u&quot;, @); }'</span></pre></div></div>

<p>lets split the dtrace call up in its most important parts:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">sudo dtrace</pre></div></div>

<p>here we execute dtrace with root privileges</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">-</span>n javascript<span style="color: #339933;">*:::</span>function<span style="color: #339933;">-</span>entry<span style="color: #3366CC;">'{ @[copyinstr(arg1), copyinstr(arg2)] = count(); }'</span></pre></div></div>

<p>The parameter &#8220;-n&#8221; tells dtrace that we are about to enable a probe matching the name following the parameter. This is &#8220;javascript*:::function-entry&#8221;.</p>
<p>Now after enabling the probe, we are telling dtrace what to do with the information we get everytime that probe gets fired. In this case we do an aggregation on the times a function gets called. Similar to an associative array we store a &#8220;key&#8221; and call the dtrace internal function count() to increment the counter for every specific function call.</p>
<p>When activating a probe and that probe gets called you have access to several probe specific arguments which you refer to using arg0, arg1, arg2, argX. The function-entry arguments are:</p>
<p><strong>arg0</strong>: filename<br />
<strong>arg1</strong>: classname<br />
<strong>arg2</strong>: funcname</p>
<p>Essentially in the above example, we are storing the class name and function name as the key for the aggregation.</p>
<p>The last unclear bit is the copyinstr call on both arg1 and arg2. copyinstr is used to copy the data from the user-space to the kernels address space. In short, copyinstr makes the information available to the dtrace script so we can output the info in a usable format.</p>
<p>The last part of the command actually is also activating a probe</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">-</span>n END<span style="color: #3366CC;">'{ printa(&quot;<span style="color: #000099; font-weight: bold;">\n</span>%-6s %-35s  %5@u&quot;, @); }'</span></pre></div></div>

<p>Here we are activating the dtrace internal END probe</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">END</pre></div></div>

<p>An exact same way of writing this would be:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">dtrace<span style="color: #339933;">:::</span>END</pre></div></div>

<p>which gets called at the very end of the dtrace execution. We use the dtrace function &#8220;printa&#8221; do return the data aggregation in a human readable format.<br />
&#8220;printa&#8221; almost works the same as &#8220;printf&#8221;, most developers should know and basically takes a format string as the first argument and aggregation variable as the second string. In this example we use following format string:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>%-6s %-35s  %5@u&quot;</span></pre></div></div>

<p>Our aggregation variable has two touple identifiers, the classname and the function name. As a third available parameter we have the aggregation value itself (@[copyinstr(arg1), copyinstr(arg2)] = count();).</p>
<p>At first we make sure we print a &#8220;\n&#8221; for each new element in the aggregation, then left-align the first touple identifier (@[<strong>copyinstr(arg1)</strong>, copyinstr(arg2)] = count();), fill up missing spaces up until 6 characters. The same we do with the second touple identifier (@[copyinstr(arg1), <strong>copyinstr(arg2)</strong>] = count();), though fill up more remaining space (up to 35 whitespaces) and at the end we display the actual aggregate information (@[copyinstr(arg1), copyinstr(arg2)] = <strong>count()</strong>;). Note the &#8220;@&#8221; in &#8220;%5@u&#8221; which is used to access the aggregation information (<strong>count();</strong>).</p>
<p>To get a full overview of possibilities to format your aggregation using printa have a look at the <a href="http://wikis.sun.com/display/DTrace/Output+Formatting">dtrace documentation</a>.</p>
<h2>A step further</h2>
<p>When debugging web-applications, we don&#8217;t want to type command line scripts every time but rather want to use a set of ready made scripts. Lets put the previous script into a file called &#8220;functioncall_count.d&#8221;:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">javascript<span style="color: #339933;">*:::</span>function<span style="color: #339933;">-</span>entry
<span style="color: #009900;">&#123;</span> 
    <span style="color: #339933;">@</span><span style="color: #009900;">&#91;</span>copyinstr<span style="color: #009900;">&#40;</span>arg1<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> copyinstr<span style="color: #009900;">&#40;</span>arg2<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> count<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span>
&nbsp;
dtrace<span style="color: #339933;">:::</span>END
<span style="color: #009900;">&#123;</span> 
    printa<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>%-6s %-35s  %5@u&quot;</span><span style="color: #339933;">,</span> <span style="color: #339933;">@</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>And execute the script using</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$ sudo dtrace <span style="color: #339933;">-</span>s functioncall_count.<span style="color: #660066;">d</span></pre></div></div>

<p>When you load up a webpage, execute a few javascript function calls and then press CTRL+C you should get the same list of function calls as we did before.</p>
<h2>Hands on optimisation</h2>
<p>Now that we have a little bit of insight into how dtrace works lets look at a bottleneck occuring very often when building web applications: <strong>interaction with the DOM</strong></p>
<p>A very often found bottleneck is the miss usage of appending DOM nodes into the DOM when being in an iteration. </p>
<p>Lets take a look at an example:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> buildMenu<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> cnt <span style="color: #339933;">=</span> <span style="color: #CC0000;">1000</span><span style="color: #339933;">,</span> node
        resultNode <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;resultNodes&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>cnt<span style="color: #339933;">&gt;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        node <span style="color: #339933;">=</span> document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;li&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        node.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Iteration &quot;</span><span style="color: #339933;">+</span>cnt<span style="color: #339933;">;</span>
        resultNode.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>node<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        cnt<span style="color: #339933;">--;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>and compare the same with following code:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> buildMenu<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> cnt <span style="color: #339933;">=</span> <span style="color: #CC0000;">1000</span><span style="color: #339933;">,</span> node
        resultNode <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;resultNodes&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        frgm <span style="color: #339933;">=</span> document.<span style="color: #660066;">createDocumentFragment</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>cnt<span style="color: #339933;">&gt;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        node <span style="color: #339933;">=</span> document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;li&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        node.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Iteration &quot;</span><span style="color: #339933;">+</span>cnt<span style="color: #339933;">;</span>
        frgm.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>node<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        cnt<span style="color: #339933;">--;</span>
    <span style="color: #009900;">&#125;</span>
    resultNode.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>frgm<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Lets write a simple dtrace script which allows us to measure the execution time of such a iteration:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">javascript<span style="color: #339933;">*:::</span>function<span style="color: #339933;">-</span>entry
<span style="color: #009966; font-style: italic;">/copyinstr(arg2) == $$1/</span>
<span style="color: #009900;">&#123;</span>
        self<span style="color: #339933;">-&gt;</span>ts <span style="color: #339933;">=</span> timestamp<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
javascript<span style="color: #339933;">*:::</span>function<span style="color: #339933;">-</span><span style="color: #000066; font-weight: bold;">return</span>
<span style="color: #009966; font-style: italic;">/copyinstr(arg2) == $$1/</span>
<span style="color: #009900;">&#123;</span>
        <span style="color: #339933;">@</span>times<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;time: &quot;</span><span style="color: #339933;">,</span> copyinstr<span style="color: #009900;">&#40;</span>arg2<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> avg<span style="color: #009900;">&#40;</span>timestamp<span style="color: #339933;">-</span>self<span style="color: #339933;">-&gt;</span>ts<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #339933;">@</span>counts<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;counts: &quot;</span><span style="color: #339933;">,</span> copyinstr<span style="color: #009900;">&#40;</span>arg2<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> count<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        self<span style="color: #339933;">-&gt;</span>ts<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>At first we see that our dtrace script activates two probes or the javascript* provider:</p>
<p><strong>function-entry<br />
function-return</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">javascript<span style="color: #339933;">*:::</span>function<span style="color: #339933;">-</span>entry
<span style="color: #009966; font-style: italic;">/copyinstr(arg2) == $$1/</span>
<span style="color: #009900;">&#123;</span>
        self<span style="color: #339933;">-&gt;</span>ts <span style="color: #339933;">=</span> timestamp<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>We see two new things:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">/</span>copyinstr<span style="color: #009900;">&#40;</span>arg2<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> $$<span style="color: #CC0000;">1</span><span style="color: #339933;">/</span></pre></div></div>

<p>and</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">self<span style="color: #339933;">-&gt;</span>ts <span style="color: #339933;">=</span> timestamp<span style="color: #339933;">;</span></pre></div></div>

<p>Dtrace doesn&#8217;t know control structuures such as if, else, if else but is using a predicative syntax.<br />
Basically all we are saying here is: &#8220;If copyinstr(arg2) equals the passed first parameter from the shell, execute the probe.&#8221;. This allows us to only watch specific functions within application execution and can save us a lot of time, analyzing data returned from a profiling/debuggin session.</p>
<p>The second unknown construct is self->ts = timestamp.<br />
&#8220;self&#8221; allows us to store data in thread local variables so we can be sure that there won&#8217;t be any race conditions in multi threaded applications. This is not really an issue in the JavaScript environment but nevertheless its good practice to work this way. &#8220;timestamp&#8221; gives us the current timestamp in nanoseconds, this is way more accurate than most of the todays browser profilers.</p>
<p>Now the code for our second probe looks like following:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">javascript<span style="color: #339933;">*:::</span>function<span style="color: #339933;">-</span><span style="color: #000066; font-weight: bold;">return</span>
<span style="color: #009966; font-style: italic;">/copyinstr(arg2) == $$1/</span>
<span style="color: #009900;">&#123;</span>
        <span style="color: #339933;">@</span>times<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;time: &quot;</span><span style="color: #339933;">,</span> copyinstr<span style="color: #009900;">&#40;</span>arg2<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> avg<span style="color: #009900;">&#40;</span>timestamp<span style="color: #339933;">-</span>self<span style="color: #339933;">-&gt;</span>ts<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #339933;">@</span>counts<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;counts: &quot;</span><span style="color: #339933;">,</span> copyinstr<span style="color: #009900;">&#40;</span>arg2<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> count<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        self<span style="color: #339933;">-&gt;</span>ts<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>We are creating two aggregations on the function name. One to calculate the average time of execution for the function and one for the amount of times that function got called.</p>
<h2>See it in action</h2>
<p>Lets take a look at a video demonstration so you can see what difference each of the two approaches make in your application.</p>
<p><object width="600" height="375"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=3421941&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=3421941&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="600" height="375"></embed></object><br /><a href="http://vimeo.com/3421941">JavaScript profiling with dtrace</a> from <a href="http://vimeo.com/uxebu">uxebu</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>To watch the video with better quality visit the <a href="http://vimeo.com/3421941?pg=embed&#038;sec=&#038;hd=1">vimeo site</a>.</p>
<h2>Results</h2>
<p>After profiling the two different approaches with dtrace we can clearly see that using DocumentFragment within an iteration is faster than appending the node to the DOM straight away. </p>
<p>Appending nodes using DocumentFragment: <strong>252ms</strong><br />
Appending nodes to the DOM within the iteration: <strong>260ms</strong></p>
<p>In our example, the complexity within the loop was still very low. If you are dealing with more complex constructs the performance gain can be significant.</p>
<h2>What&#8217;s next</h2>
<p>Until now we have seen ways to compare different implementations of the same functionality &#8211; meaning that we already have to know about a bottleneck. In the next article I will explain how we can spot potential weak spots in your application code and show you how you can use dtrace to make sure that your code optimizations are as effective as they can be.</p>
<p>We at uxebu use these techniques, when we are investigating peformance bottle necks, to find the most efficient way to interact with the DOM.</p>
]]></content:encoded>
			<wfw:commentRss>http://uxebu.com/blog/2009/03/02/firefox-on-osx-with-dtrace-part-ii/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Firefox on OSX with dtrace</title>
		<link>http://uxebu.com/blog/2009/02/20/firefox-on-osx-with-dtrace/</link>
		<comments>http://uxebu.com/blog/2009/02/20/firefox-on-osx-with-dtrace/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 12:00:03 +0000</pubDate>
		<dc:creator>Nikolai Onken</dc:creator>
				<category><![CDATA[development tools]]></category>
		<category><![CDATA[dojo]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[dtrace]]></category>
		<category><![CDATA[profiling]]></category>

		<guid isPermaLink="false">http://blog.uxebu.com/?p=119</guid>
		<description><![CDATA[After seeing a great talk by Johannes Schlueter about dtrace, I want to pass on the information and give a short introduction on how to set up your (Firefox) JavaScript development environment on OSX so you can dive into dtrace and start exploring the powerful features of this tool.

Building Firefox
it is recommended to build Firefox [...]]]></description>
			<content:encoded><![CDATA[<p>After seeing a great talk by <a href="http://schlueters.de/">Johannes Schlueter</a> about <a href="http://opensolaris.org/os/community/dtrace/">dtrace</a>, I want to pass on the information and give a short introduction on how to set up your (Firefox) JavaScript development environment on OSX so you can dive into dtrace and start exploring the powerful features of this tool.</p>
<p><span id="more-119"></span></p>
<h2>Building Firefox</h2>
<p>it is recommended to build Firefox from a release source and not from trunk since you really want to profile your app in an production environment. You can build Firefox from head though some of the plugins won&#8217;t work.</p>
<p><strong>1. Building preconditions</strong></p>
<p>To build firefox you need to make sure that a few modules are installed:</p>
<p><em>Xcode</em></p>
<p>If Xcode is not yet installed on your machine get a copy at <a href="http://developer.apple.com/technology/xcode.html">http://developer.apple.com/technology/xcode.html</a>.</p>
<p><em>Mac Ports</em></p>
<p>You need Mac Ports to make installation of the following modules much easier. Get the .dmg here <a href="http://www.macports.org/install.php">http://www.macports.org/install.php</a></p>
<p><em>Packages for building Firefox</em></p>
<p>The remaining two packages you will need from the ports repository are &#8220;libidl&#8221; and &#8220;autoconf213&#8243;<br />
After you have installed Mac ports open a terminal and run</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$ sudo port sync
$ sudo port install libidl autoconf213</pre></div></div>

<p><strong>2. Download Firefox</strong></p>
<p>For this blog article we will download the 3.0.6 release from <a href="ftp://ftp.mozilla.org/pub/mozilla.org/firefox/releases/3.0.6/source/">ftp://ftp.mozilla.org/pub/mozilla.org/firefox/releases/3.0.6/source/</a> &#8211; if you want to profile other firefox releases visit <a href="ftp://ftp.mozilla.org/pub/mozilla.org/firefox/releases/">ftp://ftp.mozilla.org/pub/mozilla.org/firefox/releases/</a> and go to the proper VERSION/source directory.</p>
<p>You can get more useful information on how to download the source from trunk (mercurial) at <a href="https://developer.mozilla.org/en/Build_Documentation#Get_the_source">https://developer.mozilla.org/en/Build_Documentation#Get_the_source</a></p>
<p>Once you have the source, move it into your home directory, extract it and go into the created &#8220;mozilla&#8221; directory in a shell.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$ cd ~
$ tar xf firefox<span style="color: #339933;">-</span>3.0.6<span style="color: #339933;">-</span>source.<span style="color: #660066;">tar</span>.<span style="color: #660066;">bz2</span> 
$ cd mozilla</pre></div></div>

<p><strong>3. Creating a build config</strong></p>
<p>Create a file in your home directory ($ cd ~) with following content and save it under .mozconfig</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">. $topsrcdir<span style="color: #339933;">/</span>browser<span style="color: #339933;">/</span>config<span style="color: #339933;">/</span>mozconfig
mk_add_options MOZ_OBJDIR<span style="color: #339933;">=@</span>TOPSRCDIR<span style="color: #339933;">@/</span>obj<span style="color: #339933;">-</span>ff
ac_add_options <span style="color: #339933;">--</span>disable<span style="color: #339933;">-</span>libxul
ac_add_options <span style="color: #339933;">--</span>enable<span style="color: #339933;">-</span>debug <span style="color: #339933;">--</span>disable<span style="color: #339933;">-</span>optimize
ac_add_options <span style="color: #339933;">--</span>enable<span style="color: #339933;">-</span>shared <span style="color: #339933;">--</span>disable<span style="color: #339933;">-</span>static <span style="color: #339933;">--</span>enable<span style="color: #339933;">-</span>dtrace
ac_add_options <span style="color: #339933;">--</span>with<span style="color: #339933;">-</span>macos<span style="color: #339933;">-</span>sdk<span style="color: #339933;">=/</span>Developer<span style="color: #339933;">/</span>SDKs<span style="color: #339933;">/</span>MacOSX10.5.<span style="color: #660066;">sdk</span>
mk_add_options MOZ_MAKE_FLAGS<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;-s -j4&quot;</span>
mk_add_options AUTOCONF<span style="color: #339933;">=</span>autoconf213</pre></div></div>

<p><strong>4. Build Firefox</strong></p>
<p>Make sure you are in the directory of the downloaded firefox source &#8211; this should be the &#8220;mozilla&#8221; directory and run</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$ cd mozilla
$ make <span style="color: #339933;">-</span>f client.<span style="color: #660066;">mk</span> build</pre></div></div>

<p><strong>5. Launch the newly build firefox</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$ cd obj<span style="color: #339933;">-</span>ff<span style="color: #339933;">/</span>dist
$ <span style="color: #000066;">open</span> MinefieldDebug.<span style="color: #660066;">app</span></pre></div></div>

<h2>Testing dtrace</h2>
<p>Fortunately dtrace already is installed on OSX 10.5 (My machine is running on 10.5.6).<br />
Open a new shell and open for instance google.com. After the page has loaded switch back to the shell and enter</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">sudo dtrace <span style="color: #339933;">-</span>n javascript<span style="color: #339933;">*:::</span>function<span style="color: #339933;">-</span>entry<span style="color: #3366CC;">'{ @[copyinstr(arg1), copyinstr(arg2)] = count(); }'</span> 
    <span style="color: #339933;">-</span>n END<span style="color: #3366CC;">'{ printa(&quot;<span style="color: #000099; font-weight: bold;">\n</span>%-6s %-35s  %5@u&quot;, @); }'</span></pre></div></div>

<p><em>(Note that you have to paste the code in one line!)</em></p>
<p>We are using the &#8220;function-entry&#8221; probe which will give us the possibility to inspect each function call within the javascript code. This example is fairly simple and is just showing us how many times a function got called.</p>
<p>Now on the Google page open the dropdown of the top menu and close it again.<br />
Back in the shell, terminate dtrace by pressing &#8220;CTRL+C&#8221; and inspect the output.</p>
<p>It should look similar to this</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">CPU     ID                    <span style="color: #003366; font-weight: bold;">FUNCTION</span><span style="color: #339933;">:</span><span style="color: #000066;">NAME</span>
  <span style="color: #CC0000;">1</span>      <span style="color: #CC0000;">2</span>                             <span style="color: #339933;">:</span>END 
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> abs                                      <span style="color: #CC0000;">1</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> autosave_disable_buttons                 <span style="color: #CC0000;">1</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> autosave_enable_buttons                  <span style="color: #CC0000;">1</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> autosave_parse_response                  <span style="color: #CC0000;">1</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> autosave_saved                           <span style="color: #CC0000;">1</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> autosave_update_preview_link             <span style="color: #CC0000;">1</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> autosave_update_slug                     <span style="color: #CC0000;">1</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> <span style="color: #000066;">blur</span>                                     <span style="color: #CC0000;">1</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> clearInterval                            <span style="color: #CC0000;">1</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> complete                                 <span style="color: #CC0000;">1</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> isNaN                                    <span style="color: #CC0000;">1</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> <span style="color: #000066;">open</span>                                     <span style="color: #CC0000;">1</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> send                                     <span style="color: #CC0000;">1</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> setInterval                              <span style="color: #CC0000;">1</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> success                                  <span style="color: #CC0000;">1</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> getResponseHeader                        <span style="color: #CC0000;">2</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> j                                        <span style="color: #CC0000;">2</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> join                                     <span style="color: #CC0000;">2</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> match                                    <span style="color: #CC0000;">2</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> parseInt                                 <span style="color: #CC0000;">2</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> removeChild                              <span style="color: #CC0000;">2</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> appendChild                              <span style="color: #CC0000;">3</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> goUpdateGlobalEditMenuItems              <span style="color: #CC0000;">3</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> goUpdatePlacesCommands                   <span style="color: #CC0000;">3</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> removeAttribute                          <span style="color: #CC0000;">3</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> setRequestHeader                         <span style="color: #CC0000;">3</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> createElement                            <span style="color: #CC0000;">4</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> toString                                 <span style="color: #CC0000;">7</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> valueOf                                  <span style="color: #CC0000;">7</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> substr                                  <span style="color: #CC0000;">11</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> isCommandEnabled                        <span style="color: #CC0000;">12</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> concat                                  <span style="color: #CC0000;">13</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> setTimeout                              <span style="color: #CC0000;">15</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> substring                               <span style="color: #CC0000;">16</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> goUpdateCommand                         <span style="color: #CC0000;">24</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> encodeURIComponent                      <span style="color: #CC0000;">26</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> getControllerForCommand                 <span style="color: #CC0000;">27</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> toLowerCase                             <span style="color: #CC0000;">27</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> getElementsByTagName                    <span style="color: #CC0000;">31</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> updatePlacesCommand                     <span style="color: #CC0000;">36</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> goSetCommandEnabled                     <span style="color: #CC0000;">60</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> setAttribute                            <span style="color: #CC0000;">61</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> split                                   <span style="color: #CC0000;">64</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> getElementById                          <span style="color: #CC0000;">92</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> apply                                  <span style="color: #CC0000;">191</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> replace                                <span style="color: #CC0000;">223</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> test                                   <span style="color: #CC0000;">268</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> exec                                   <span style="color: #CC0000;">356</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> getAttribute                           <span style="color: #CC0000;">359</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> toUpperCase                            <span style="color: #CC0000;">376</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> shift                                  <span style="color: #CC0000;">482</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> unshift                                <span style="color: #CC0000;">546</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> call                                   <span style="color: #CC0000;">654</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> indexOf                                <span style="color: #CC0000;">835</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> push                                  <span style="color: #CC0000;">2329</span>
<span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;</span>null<span style="color: #339933;">&gt;</span>                                <span style="color: #CC0000;">6251</span></pre></div></div>

<p>In the next blog post I will explain how we can write more complex dtrace scripts which give us deeper insight into profiling our applications performance. We merely have covered the tip of the dtrace iceberg so watch out for the next dtrace update.</p>
<p>Thanks Johannes for the great talk!</p>
]]></content:encoded>
			<wfw:commentRss>http://uxebu.com/blog/2009/02/20/firefox-on-osx-with-dtrace/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
