<?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/"
	xmlns:series="http://organizeseries.com/"
	>

<channel>
	<title>SitePen Blog</title>
	<atom:link href="http://www.sitepen.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sitepen.com/blog</link>
	<description>SitePen Services and notes about Dojo, Persevere, CometD, JavaScript, and the Web</description>
	<lastBuildDate>Wed, 15 May 2013 22:02:34 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5</generator>
		<item>
		<title>Dojo FAQ: Is there a way to extend a widget&#8217;s template (e.g. Dialog)?</title>
		<link>http://www.sitepen.com/blog/2013/05/15/faq-edit-widget-template/</link>
		<comments>http://www.sitepen.com/blog/2013/05/15/faq-edit-widget-template/#comments</comments>
		<pubDate>Wed, 15 May 2013 22:02:34 +0000</pubDate>
		<dc:creator>Mangala SSS Khalsa</dc:creator>
				<category><![CDATA[Dojo]]></category>
		<category><![CDATA[FAQ]]></category>

		<guid isPermaLink="false">http://www.sitepen.com/blog/?p=6510</guid>
		<description><![CDATA[<p>There are indeed ways of doing so, but while Dijit strives to provide extensible modules that can serve as a basis for your own custom modules, templates are a tricky thing to deal with. A brief review of some of the best practices for maintenance &#38; longevity when building applications with Dojo: Use a separate [...]</p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></description>
				<content:encoded><![CDATA[<p>There are indeed ways of doing so, but while Dijit strives to provide extensible modules that can serve as a basis for your own custom modules, templates are a tricky thing to deal with.</p>
<p>A brief review of some of the best practices for maintenance &amp; longevity when building applications with Dojo:</p>
<ul>
<li><span style="line-height: 13px;" data-mce-mark="1">Use a separate namespace for your custom modules rather than dojo, dijit, or dojox &#8211; this makes it very clear which modules come from the Dojo distribution and which modules were created for your application or organization</span></li>
<li>Never edit Dojo modules directly &#8211; Dojo provides <code>dojo/_base/declare</code> for inheritance and provides many modules that were designed to be extended or used as mixins</li>
</ul>
<p>With a clear separation in your codebase between Dojo modules and custom modules created for your application you have a much greater chance of a simple &amp; successful upgrade to a new release of Dojo.</p>
<p><span id="more-6510"></span></p>
<p>If you find yourself wanting to edit a Dijit&#8217;s template, you should first see if you can meet your needs using CSS or the widget&#8217;s content area. By inspecting the DOM of Dijits rendered in a page, you can see the element structure and CSS rules applied. You can override the CSS rules using the same selectors simply by including your custom CSS after Dijit&#8217;s CSS has been loaded. Dialog, layout, and container Dijits are explicitly designed to display arbitrary content, so see if you can place your custom elements in the content area.</p>
<p>If you have really exhausted other possibilities and feel a need to significantly modify a Dijit&#8217;s DOM, it&#8217;s best to leave the existing template intact &#8211; the code for the widget is expecting a certain DOM structure and may fail if you remove or rearrange elements. One approach is to copy the Dijit&#8217;s template, edit it to meet your needs, and use it in your own custom widget that extends the original Dijit. If you feel OK with keeping your modified template up-to-date with the base template as you update the release of Dojo you use, this approach may work for you.</p>
<p>A somewhat complicated, but more resilient approach would be to programmatically add your elements to the DOM in your custom widget&#8217;s <code>buildRendering</code> method. Don&#8217;t remove existing elements &#8211; you may be able to get away with hiding them, but removing them may lead to code errors. Since the DOM structure has potential to change with new releases of Dojo, you should locate an element that has an attach point, as these are less prone to change. Insert your custom DOM nodes, or even other widgets, into the Dijit&#8217;s DOM with an attach point node as the reference for positioning. With this approach, your custom widget is more likely to continue working unmodified as you upgrade your application to use new releases of Dojo.</p>
<p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sitepen.com/blog/2013/05/15/faq-edit-widget-template/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dojo FAQ: Does Dijit have a confirm dialog?</title>
		<link>http://www.sitepen.com/blog/2013/05/08/dojo-faq-dijit-confirm-dialog-best-practices/</link>
		<comments>http://www.sitepen.com/blog/2013/05/08/dojo-faq-dijit-confirm-dialog-best-practices/#comments</comments>
		<pubDate>Wed, 08 May 2013 17:01:54 +0000</pubDate>
		<dc:creator>Mangala SSS Khalsa</dc:creator>
				<category><![CDATA[Dojo]]></category>
		<category><![CDATA[FAQ]]></category>

		<guid isPermaLink="false">http://www.sitepen.com/blog/?p=6503</guid>
		<description><![CDATA[<p>No, Dijit does not provide pre-configured dialogs, like alert, confirm, or prompt. Why? As simple as these may seem on the surface, each organization or application often needs something subtly different in terms of layout, appearance, behavior, events, and internationalization. Dojo and Dijit provide all the elements you need to make a variety of dialogs, [...]</p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></description>
				<content:encoded><![CDATA[<p>No, Dijit does not provide pre-configured dialogs, like alert, confirm, or prompt.</p>
<p>Why? As simple as these may seem on the surface, each organization or application often needs something subtly different in terms of layout, appearance, behavior, events, and internationalization. Dojo and Dijit provide all the elements you need to make a variety of dialogs, including <a href="http://dojotoolkit.org/reference-guide/dijit/Dialog.html"><code>dijit/Dialog</code></a>, <a href="http://dojotoolkit.org/reference-guide/dijit/form/Button.html"><code>dijit/form/Button</code></a>, <a href="http://dojotoolkit.org/reference-guide/dojo/on.html"><code>dojo/on</code></a>, <a href="http://dojotoolkit.org/reference-guide/dojo/Deferred.html"><code>dojo/Deferred</code></a> and <a href="http://dojotoolkit.org/reference-guide/dojo/i18n.html"><code>dojo/i18n</code></a>.</p>
<p>The time spent creating a dialog that suits your needs perfectly will be small compared to the overall time spent developing an application, and you will have a reusable module tailored to your specific needs that you can use throughout your application, or even across applications throughout your organization. Creating a custom dialog also ensures that teams of developers don&#8217;t have to struggle to get a generic confirmation dialog to respond and look like other dialogs in the application.</p>
<p>That being said, Dojo is an open-source, community-driven project, and you are encouraged to share general-purpose components with the community:</p>
<ul>
<li><a href="http://packages.dojofoundation.org/">Dojo Foundation Packages</a></li>
<li><a href="http://www.sitepen.com/blog/2011/07/25/dojo-foundation-packages/">Dojo Foundation Packages and Phasing out DojoX</a></li>
</ul>
<p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sitepen.com/blog/2013/05/08/dojo-faq-dijit-confirm-dialog-best-practices/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dojo FAQ: Why doesn&#8217;t my BorderContainer display?</title>
		<link>http://www.sitepen.com/blog/2013/05/02/dojo-faq-bordercontainer-not-visible/</link>
		<comments>http://www.sitepen.com/blog/2013/05/02/dojo-faq-bordercontainer-not-visible/#comments</comments>
		<pubDate>Thu, 02 May 2013 16:52:42 +0000</pubDate>
		<dc:creator>Mangala SSS Khalsa</dc:creator>
				<category><![CDATA[Dojo]]></category>
		<category><![CDATA[FAQ]]></category>

		<guid isPermaLink="false">http://www.sitepen.com/blog/?p=6542</guid>
		<description><![CDATA[<p>One of the most common questions we get asked is why a BorderContainer may not be displaying. There are two very common gotchas that we typically see when it comes to BorderContainer use. Width/height issues The most common culprit when your dijit/layout/BorderContainer doesn&#8217;t display at all is forgetting to set the width and height of [...]</p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></description>
				<content:encoded><![CDATA[<p>One of the most common questions we get asked is why a BorderContainer may not be displaying. There are two very common gotchas that we typically see when it comes to BorderContainer use.</p>
<h2>Width/height issues</h2>
<p>The most common culprit when your <a href="http://dojotoolkit.org/reference-guide/dijit/layout/BorderContainer.html"><code>dijit/layout/BorderContainer</code></a> doesn&#8217;t display at all is forgetting to set the width and height of the <code>html</code> and <code>body</code> elements. Somewhat counter-intuitively, these elements default to a width and height of 0, only expanding to fill content.</p>
<p>A <code>BorderContainer</code> is often configured to expand to fill its container node like so:</p>
<pre class="brush: css">#borderContainer {
    width: 100%;
    height: 100%;
}</pre>
<p>In a typical scenario, if all you have on a page is a <code>BorderContainer</code> directly under the <code>body</code> element, the <code>body</code> will have height and width of 0, so the <code>BorderContainer</code> will calculate the space it has to work in and will fill 100% of&#8230; no space! That is, unless you set width and height explicitly, like so:</p>
<pre class="brush: css">html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}</pre>
<p>With the <code>html</code> and <code>body</code> elements configured to use the full viewport, your BorderContainer will be able to expand as you would expect.</p>
<h2>Did your widget start?</h2>
<p>As with all Dijit widgets, if you are using <code>BorderContainer</code> programmatically, you need to ensure that you explicitly call <code>startup</code> after creating it and putting it into the document:</p>
<pre class="brush: js">require([
    'dijit/layout/BorderContainer'
], function(BorderContainer){
    var mainContainer = new BorderContainer({
        id: 'mainContainer',
        design: 'headline'
    });
    mainContainer.placeAt(document.body);
    mainContainer.startup();
});</pre>
<h2>In Closing</h2>
<p>If your <code>BorderContainer</code> fails to display, check two things:</p>
<ul>
<li>The size of the <code>BorderContainer's</code> containing element &#8211; if it&#8217;s the <code>body</code> element, make sure both the <code>html</code> and <code>body</code> elements are sized appropriately.</li>
<li>If using <code>BorderContainer</code> programmatically, ensure that you have called its <code>startup</code> method after creating and placing it.</li>
</ul>
<p>If it still isn&#8217;t showing up, check your console and make sure there are no errors &#8212; a parsing error will often cause subsequent content to not display correctly.</p>
<p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sitepen.com/blog/2013/05/02/dojo-faq-bordercontainer-not-visible/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Meet your newest Intern</title>
		<link>http://www.sitepen.com/blog/2013/05/01/intern-javascript-testing/</link>
		<comments>http://www.sitepen.com/blog/2013/05/01/intern-javascript-testing/#comments</comments>
		<pubDate>Wed, 01 May 2013 16:10:40 +0000</pubDate>
		<dc:creator>Paul Bouchon</dc:creator>
				<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.sitepen.com/blog/?p=6252</guid>
		<description><![CDATA[<p>JavaScript tooling has gained a huge amount of attention over the past few years, no doubt due to the language’s rapidly increasing popularity and maturity. Many fantastic utilities and powerful debuggers have emerged to help close painful gaps for Web developers, but despite these advancements, high-quality JavaScript testing is still notably absent. Up to this [...]</p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></description>
				<content:encoded><![CDATA[<p><a href="http://theintern.io"><img src="http://www.sitepen.com/blog/wp-content/uploads/2013/05/intern_blog1.png" alt="The Intern" width="196" height="197" style="float:right"></a>
<p>JavaScript tooling has gained a huge amount of attention over the past few years, no doubt due to the language’s rapidly increasing popularity and maturity. Many fantastic utilities and powerful debuggers have emerged to help close painful gaps for Web developers, but despite these advancements, <strong>high-quality JavaScript testing is still notably absent</strong>.</p>
<p>Up to this point, JavaScript authors have had to pick and choose testing tools with incredibly fragmented feature sets. Whereas one tool might support easily running tests manually in many browsers, another might allow command-line automation but only use PhantomJS. A third might be designed to integrate with a continuous integration service, where a fourth might support none of that but allow you to emulate true browser events from outside the JavaScript sandbox. One might have so many plugins that it’s impossible to figure out which ones to use, whereas another might be so inflexible that adding any new features is impossible. It’s a mess.</p>
<p><a href="http://theintern.io">Intern</a>, from SitePen Labs, is different. It combines <a href="https://github.com/theintern/intern/#features">all the best features</a> from various testing tools (plus a few new ones of our own) into a single, versatile, easy-to-use, standards-based browser testing stack for JavaScript. We’ve been using this testing framework internally for a while with great success and are really excited to be able to make this level of JavaScript testing available to the entire Web community.</p>
<p>For more information on Intern’s features, usage examples, and documentation, please visit the <a href="http://theintern.io">Intern Web site</a>. If you just want to get started straight away, take a look at the <a href="https://github.com/theintern/intern#quick-start">quick start guide</a>. We’ll be making an npm package available very soon to make getting started even easier. Bug reports and feature requests can be posted to the <a href="https://github.com/theintern/intern/issues">GitHub issue tracker</a>. If you have any other questions, we’re here to help! Free end-user support is currently available via <a href="http://stackoverflow.com/questions/ask?tags=intern">Stack Overflow</a>. SitePen also offers <a href="http://www.sitepen.com/support/index.html">commercial JavaScript support</a> if you need a little extra TLC.</p>
<p>Please let us know in the comments how Intern can work better for you, so you can focus on delivering high-quality code while the Intern does the testing. Happy coding!</p>
<p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sitepen.com/blog/2013/05/01/intern-javascript-testing/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Dojo FAQ: What properties are available to me on the event object when using dojo/on?</title>
		<link>http://www.sitepen.com/blog/2013/04/26/dojo-faq-what-properties-do-events-come-with-via-dojoon/</link>
		<comments>http://www.sitepen.com/blog/2013/04/26/dojo-faq-what-properties-do-events-come-with-via-dojoon/#comments</comments>
		<pubDate>Fri, 26 Apr 2013 18:20:06 +0000</pubDate>
		<dc:creator>Mangala SSS Khalsa</dc:creator>
				<category><![CDATA[Dojo]]></category>
		<category><![CDATA[FAQ]]></category>

		<guid isPermaLink="false">http://www.sitepen.com/blog/?p=6471</guid>
		<description><![CDATA[<p>The dojo/on module not only provides a simple, consistent interface for registering event handlers, it also ensures that the event object passed to your handler implements the W3C event model (W3C recommendation, MDN reference). While most web browsers provide DOM events in a manner compliant with the W3C model, prior to version 9 Internet Explorer [...]</p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></description>
				<content:encoded><![CDATA[<p>The <a href="http://dojotoolkit.org/reference-guide/dojo/on.html"><code>dojo/on</code></a> module not only provides a simple, consistent interface for registering event handlers, it also ensures that the <code>event</code> object passed to your handler implements the W3C event model (<a href="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-Event">W3C recommendation</a>, <a href="https://developer.mozilla.org/en-US/docs/DOM/event">MDN reference</a>).</p>
<p>While most web browsers provide DOM events in a manner compliant with the W3C model, prior to version 9 Internet Explorer implemented its own model with the <a href="http://msdn.microsoft.com/en-us/library/ie/ms536343(v=vs.85).aspx"><code>attachEvent</code></a> method and some different properties on the <code>event</code> object.</p>
<p>Using <code>dojo/on</code> allows you to interact with event objects using the W3C event model regardless of the web browser. Specifically, the following properties and methods are added to <code>event</code> objects in IE8 and below (see the <a href="https://developer.mozilla.org/en-US/docs/DOM/event">MDN reference</a> for details &#8211; keep in mind some properties only apply to certain event types, like <a href="https://developer.mozilla.org/en-US/docs/DOM/KeyboardEvent">KeyboardEvent</a> and <a href="https://developer.mozilla.org/en-US/docs/DOM/MouseEvent">MouseEvent</a>):</p>
<ul>
<li>target</li>
<li>currentTarget</li>
<li>relatedTarget</li>
<li>charCode</li>
<li>keyChar</li>
<li>charOrCode</li>
<li>stopPropagation()</li>
<li>stopImmediatePropagation()</li>
<li>preventDefault()</li>
</ul>
<h2>Non-standard MouseEvent Properties</h2>
<p>The properties <code>pageX</code>, <code>pageY</code>, <code>offsetX</code>, <code>offsetY</code>, <code>layerX</code>, and <code>layerY</code> are not normalized as it is expensive and often not needed, but the <code><a href="http://dojotoolkit.org/reference-guide/dojo/dom-geometry.html">dojo/dom-geometry</a></code> module provides a convenient method for doing so: <a href="http://dojotoolkit.org/reference-guide/dojo/dom-geometry/normalizeEvent.html"><code>normalizeEvent</code></a>.</p>
<pre class="brush: js">require([
    'dojo/on',
    'dojo/dom-geometry'
], function(on, domGeom){
    on('button', 'click', function(event){
        domGeom.normalizeEvent(event);
        console.log(event.pageX, event.offsetY, event.layerX);
    });
});</pre>
<h2>In Closing</h2>
<p>Using Dojo provides an easy, consistent API across web browsers, smoothing out incompatibilities and inconsistencies, with a focus on adhering to open standards. Even if you&#8217;re not ready to update existing code that depends on certain properties (like <code>layerX</code>, <code>layerY</code>), you can still start using Dojo and take advantage of normalization methods to ensure your existing code works as expected.</p>
<p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sitepen.com/blog/2013/04/26/dojo-faq-what-properties-do-events-come-with-via-dojoon/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dojo FAQ: dojo/domReady vs dojo/ready</title>
		<link>http://www.sitepen.com/blog/2013/04/17/dojodomready-vs-dojoready/</link>
		<comments>http://www.sitepen.com/blog/2013/04/17/dojodomready-vs-dojoready/#comments</comments>
		<pubDate>Wed, 17 Apr 2013 15:55:19 +0000</pubDate>
		<dc:creator>Matthew Maxwell</dc:creator>
				<category><![CDATA[Dojo]]></category>
		<category><![CDATA[FAQ]]></category>

		<guid isPermaLink="false">http://www.sitepen.com/blog/?p=6429</guid>
		<description><![CDATA[<p>We answer many, many, many questions on a daily basis through our Dojo training workshops, JavaScript support plans and during our customers&#8217; development projects. We have bucket-loads of answered questions. What to do with them all&#8230; Oh? Provide you with the answers? Ok. Here it is! Each week we&#8217;ll answer a commonly asked question about [...]</p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></description>
				<content:encoded><![CDATA[<p>We answer many, many, many questions on a daily basis through our <a href="http://www.sitepen.com/workshops/index.html">Dojo training workshops</a>, <a href="http://www.sitepen.com/support/index.html" target="_blank">JavaScript support plans</a> and during our customers&#8217; development projects.</p>
<p>We have bucket-loads of answered questions. What to do with them all&#8230;<br />
Oh? Provide you with the answers?  Ok.</p>
<p>Here it is!  Each week we&#8217;ll answer a commonly asked question about Dojo and then we&#8217;ll give it to you.  Here we go!</p>
<p><span id="more-6429"></span></p>
<p>
A question we commonly get is what the difference between <a href="http://dojotoolkit.org/reference-guide/1.8/dojo/domReady.html">dojo/domReady</a> and <a href="http://dojotoolkit.org/reference-guide/1.8/dojo/ready.html">dojo/ready</a> is and why we would actually choose one over the other. In order to understand the answer to this question, let&#8217;s quickly look at how they work under the hood.
</p>
<p><!--more--></p>
<h3>dojo/domReady</h3>
<pre class="javascript">
require(["dojo/domReady!"], function () {
	console.log("The DOM is ready");
});
</pre>
<pre class="javascript">
require(["dojo/domReady"], function (domReady) {
	domReady(function () {
		console.log("The DOM is ready");
	});
});
</pre>
<p>
The most common use of <code>dojo/domReady</code> is as a plugin in a <code>require</code> call, but it can also be used as a function. In order to determine when the DOM is ready, <code>domReady</code> listens for the <code>DOMContentLoaded</code> event where available and <code>window.onload</code> as a fallback. If the document is not yet ready, it will queue any registered callbacks, and will execute them in the order that they are queued. If used after the DOM is ready, the callback is immediately invoked.
</p>
<h3>dojo/ready</h3>
<pre class="javascript">
require(["dojo/ready"], function (ready) {
	ready(function () {
		console.log("The DOM is ready");
	});
});
</pre>
<pre class="javascript">
require(["dojo/ready"], function (ready) {
	ready(100, function () {
		console.log("The DOM is ready");
	});

	ready(1, function () {
		console.log("This fires first");
	});
});
</pre>
<p>
The <code>dojo/ready</code> module provides a function that registers a callback that will run once three conditions have met:</p>
<ol>
<li>The DOM is ready</li>
<li>All outstanding modules of requested code have completed loading</li>
<li>Other registered functions with a higher priority have completed.</li>
</ol>
<p>
It can take up to three parameters:
</p>
<ul>
<li><code>priority</code> signifies the order in which to execute the callback relative to other registered callbacks, where lower values are considered higher priority. This argument is optional, defaults to 1000, and must be a number.</li>
<li><code>context</code> is the context in which to execute the registered callback (the value of <code>this</code> in the invocation). This argument is optional.</li>
<li><code>callback</code> is the function to be registered. It is required.</li>
</ul>
<p>
Internally, <code>dojo/ready</code> uses <code>dojo/domReady</code> to determine when the DOM has loaded. Additionally, the <code>dojo/parser</code> module uses <code>dojo/ready</code> to queue up its automatic parse when <code>parseOnLoad</code> is set to <code>true</code>, so it can be used to ensure that the parse has completed before you perform further work that may be dependent on the fully parsed page.
</p>
<h3>Determining the right module to use</h3>
<p>
As you can see, the primary difference between <code>dojo/domReady</code> and <code>dojo/ready</code> is that <code>dojo/ready</code> allows you to specify a priority and context, and <code>dojo/ready</code> cannot be used as a plugin, like <code>dojo/domReady</code>. Additionally, <code>dojo/ready</code> waits for all requested code to finish loading, as opposed to simply just waiting on the DOM to be ready. Given these differences, we can easily determine the appropriate time for each module.
</p>
<p>
If you need to ensure that your callbacks execute in a set order, or they need to wait for things like all modules of code to finish loading, <code>dojo/ready</code> is the right choice. If you&#8217;re depending on <code>parseOnLoad</code> in your application, you need to use <code>dojo/ready</code>.
</p>
<p>
If you don&#8217;t need to wait for all code other than your dependencies to complete loading, or you don&#8217;t need to worry about the parsed results, <code>dojo/domReady</code> is the recommended solution, as it requires no changes to your code other than adding the <code>dojo/domReady!</code> dependency to your <code>require</code> call.
</p>
<h3>In Closing</h3>
<p>
As you can see, both of these modules are useful and have their purposes in registering callbacks to fire when the DOM is ready. If you&#8217;re interested in diving into the Dojo Toolkit more, SitePen offers a number of <a href="http://www.sitepen.com/workshops">workshops</a> that will help broaden and deepen your knowledge of Dojo!</p>
<p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sitepen.com/blog/2013/04/17/dojodomready-vs-dojoready/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing dojo-amd-converter</title>
		<link>http://www.sitepen.com/blog/2013/04/03/introducing-dojo-amd-converter/</link>
		<comments>http://www.sitepen.com/blog/2013/04/03/introducing-dojo-amd-converter/#comments</comments>
		<pubDate>Wed, 03 Apr 2013 16:30:10 +0000</pubDate>
		<dc:creator>Dylan Schiemann</dc:creator>
				<category><![CDATA[AMD]]></category>
		<category><![CDATA[Dojo]]></category>
		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://www.sitepen.com/blog/?p=6299</guid>
		<description><![CDATA[<p>AMD offers many benefits over the legacy Dojo module syntax. While Dojo is forwards-compatible, to take advantage of the benefits of AMD, developers are often faced with the challenge of migrating and refactoring large quantities of boilerplate code from the legacy dojo.provide/dojo.require syntax to AMD&#8217;s define and require. As we make the upgrade to AMD [...]</p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.sitepen.com/blog/2012/06/25/amd-the-definitive-source/">AMD offers many benefits</a> over the legacy Dojo module syntax. While Dojo is forwards-compatible, to take advantage of the benefits of AMD, developers are often faced with the challenge of migrating and refactoring large quantities of boilerplate code from the legacy <code>dojo.provide/dojo.require</code> syntax to AMD&#8217;s <code>define</code> and <code>require</code>. As we make the upgrade to AMD in our projects, we also usually want to leverage the latest version of our evolving APIs. With early work beginning on Dojo 2.0, we definitely need to work together as a community to automate as much of the upgrade process as possible.</p>
<h2>Introducing the dojo-amd-converter</h2>
<p>We have created an alpha quality release of <a href="https://github.com/SitePen/dojo-amd-converter">dojo-amd-converter</a>, a tool for helping you make a one-time migration of your existing source code to a newer version of Dojo.</p>
<p>Be warned, the tool handles only 70-80% of the manual conversion process, and generally does better with more standard usage of Dojo. Normally we wait a bit longer before announcing our projects, but this should be useful in its early alpha state. We know this tool has quite a few open issues that need to be fixed and we invite you to help us improve it.</p>
<p>Our hope is that this conversion tool, which is today useful for converting pre-AMD code to AMD code, could also form the basis for a community effort to make it possible to migrate code bases more efficiently from Dojo 1.x (pre-AMD or AMD) to Dojo 2.x. That work has not yet started, since Dojo 2.0 is not yet an actual thing.</p>
<p><span id="more-6299"></span></p>
<h2>What does it do?</h2>
<p>Based on a <a href="https://github.com/SitePen/dojo-amd-converter/blob/master/handlers.js">collection of rules</a>, and leveraging Node.js, libxml.js, and esprima, the parser will take an existing Dojo source tree, and convert the following:</p>
<ul>
<li>non-AMD modules to AMD modules</li>
<li>namespace references to module references</li>
<li>legacy HTML custom attributes to HTML5 compliant data-dojo-*</li>
<li>legacy i18n bundles to AMD bundles</li>
<li>older Dojo APIs to their refined replacements</li>
</ul>
<p>For example, if before conversion you had a file like this:</p>
<pre lang="javascript">
dojo.provide("my.namespace.i18n.Bundle");
dojo.requireLocalization("dijit", "common");
dojo.requireLocalization("foo.package", "Bundle");
dojo.requireLocalization("bar.package", "Bundle2");

var foo = dojo.i18n.getLocalization("foo.package", "Bundle"),
	bar = dojo.i18n.getLocalization("bar.package", "Bundle2", foo.bar),
	baz = {
		locale: "en-lol",
		i18n: dojo.i18n.getLocalization("bar.package", "Bundle2", this.locale)
	};
</pre>
<p>You would end up with this, after conversion:</p>
<pre lang="javascript">
define([
	"dojo",
	"dojo/i18n",
	"dojo/i18n!bar/package/nls/Bundle2",
	"dojo/i18n!dijit/nls/common",
	"dojo/i18n!foo/package/nls/Bundle"
], function (dojo, i18n, i18nBundle2, i18ncommon, i18nBundle) {

	var foo = i18nBundle,
		bar = i18n.getLocalization("bar.package", "Bundle2", foo.bar),
		baz = {
			locale: "en-lol",
			i18n: i18n.getLocalization("bar.package", "Bundle2", this.locale)
		};
});
</pre>
<h2>Usage</h2>
<p>To use the dojo-amd-converter, Mac and Linux users should follow these simple steps:</p>
<ol>
<li>Clone the repo using Git:
<pre lang="bash">git clone --recursive https://github.com/SitePen/dojo-amd-converter.git</pre>
</li>
<li>Modify the provided config.js file to specify some basic settings for your application, such as your source and destination directories.</li>
<li>From within the repo, run the provided shell script on your configuration file:
<pre lang="bash">./parse.sh config.js</pre>
</ol>
<div class="tip">If you receive a permission denied error, you may need to chmod the shell script:</p>
<pre lang="bash">chmod +x parse.sh</pre>
</div>
<h2>config.js options</h2>
<ul>
<li><code>excludePaths</code> &#8211; An array of paths that will be excluded from processing.  Each path should be a regular expression</li>
<li><code>srcDir</code> &#8211; Root directory of the files to process.</li>
<li><code>distDir</code> &#8211; Output directory of the processed files.</li>
<li><code>printOutput</code> &#8211; Print output instead of sending it to the output directory.</li>
<li><code>makeDeclareAnonymous</code> &#8211; Make declare calls anonymous instead of leaving the first argument as-is.  This will avoid creating any global variables with declare.</li>
<li><code>removeUnusedDependencies</code> &#8211; Remove dependencies that are not referenced in a converted module.</li>
<li><code>onlyProcessTemplates</code> &#8211; Only process HTML files inside template directories.</li>
</ul>
<p>The AMD converter <a href="https://github.com/SitePen/dojo-amd-converter/issues/25">does not currently work on Windows</a>, due to the dependency on libxmljs.</p>
<h2>Getting Involved</h2>
<p>This project is in the early stages, and our hope is that it will also be used for work to convert to Dojo 2.0. We have <a href="https://github.com/SitePen/dojo-amd-converter/issues">many open issues</a> for items we have already identified in our work using this tool. The dojo-amd-converter tool is <a href="https://github.com/SitePen/dojo-amd-converter/blob/master/LICENSE">licensed</a> under the same terms and conditions as other Dojo Foundation projects.</p>
<p>To get involved, you will need to have a <a href="http://dojofoundation.org/about/cla">Dojo Foundation CLA on file</a> for us to consider your code change. Please get involved if this tool is of interest to you now or in the future, as we think it is a much needed improvement for making it easier to upgrade between Dojo releases.</p>
<p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sitepen.com/blog/2013/04/03/introducing-dojo-amd-converter/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Dojo Tutorial: Feature Detection and Device Optimized Builds</title>
		<link>http://www.sitepen.com/blog/2013/01/25/dojo-tutorial-feature-detection-and-device-optimized-builds/</link>
		<comments>http://www.sitepen.com/blog/2013/01/25/dojo-tutorial-feature-detection-and-device-optimized-builds/#comments</comments>
		<pubDate>Fri, 25 Jan 2013 22:50:41 +0000</pubDate>
		<dc:creator>Dylan Schiemann</dc:creator>
				<category><![CDATA[Dojo]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.sitepen.com/blog/?p=6094</guid>
		<description><![CDATA[<p>As part of our great updates to the Dojo Tutorials for Dojo 1.8, we&#8217;ve been busy creating several new tutorials. Feature Detection and Device Optimized Builds Dojo 1.7+ now uses the popular has() pattern for feature detection in combination with a has()-aware build system. While it is easy enough to write feature detection tests with [...]</p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></description>
				<content:encoded><![CDATA[<p>As part of our great updates to the <a href="http://dojotoolkit.org/documentation/?ver=1.8">Dojo Tutorials for Dojo 1.8</a>, we&#8217;ve been busy creating several new tutorials.</p>
<h2>Feature Detection and Device Optimized Builds</h2>
<p><img src="http://www.sitepen.com/blog/wp-content/uploads/2013/01/preview.jpg" alt="preview" width="200" height="200" class="alignnone size-full wp-image-5813" style="float:left; margin:0 1em 1em 0" /> Dojo 1.7+ now uses the popular <code>has()</code> pattern for feature detection in combination with a has()-aware build system. While it is easy enough to write feature detection tests with ad-hoc JavaScript expressions, the has() pattern defines a specific syntax such that the build system can detect these feature-based branches, and one can create application builds that are highly optimized for specific devices, with known feature shims factored out. </p>
<p><strong>Check out the <a href="http://dojotoolkit.org/documentation/tutorials/1.8/device_optimized_builds/">Feature Detection and Device Optimized Builds tutorial for Dojo 1.8</a> and <a href="http://dojotoolkit.org/documentation/tutorials/1.7/device_optimized_builds/">1.7</a>!</strong> </p>
<h2>Want to see a specific Tutorial? Want to Learn More?</h2>
<p>Is there something you’d like to learn how to do with Dojo? Always wanted to know how something in Dojo works? Leave us a message in the blog comments and we’ll see about getting a tutorial created for you. Or <a href="http://www.sitepen.com/workshops/">sign-up for an upcoming SitePen Dojo Workshop</a> to get a fully immersive hands-on experience with Dojo.</p>
<p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sitepen.com/blog/2013/01/25/dojo-tutorial-feature-detection-and-device-optimized-builds/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Performance Comparison: dgrid OnDemandGrid and Dojo Grid</title>
		<link>http://www.sitepen.com/blog/2013/01/24/performance-comparison-dgrid-ondemandgrid-and-dojo-grid/</link>
		<comments>http://www.sitepen.com/blog/2013/01/24/performance-comparison-dgrid-ondemandgrid-and-dojo-grid/#comments</comments>
		<pubDate>Thu, 24 Jan 2013 16:22:26 +0000</pubDate>
		<dc:creator>Betsy Gamrat</dc:creator>
				<category><![CDATA[dgrid]]></category>
		<category><![CDATA[Dojo]]></category>
		<category><![CDATA[Dojo Grid]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://www.sitepen.com/blog/?p=5919</guid>
		<description><![CDATA[<p>SitePen&#8217;s dgrid project leverages the AMD loader and other features new since Dojo 1.7 to minimize the load and rendering times of dynamic grids in web applications. In this post, we conduct tests in four common scenarios for both dgrid and DojoX DataGrid, contrasting startup, render, and destroy times in several popular browsers. We also [...]</p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></description>
				<content:encoded><![CDATA[<style>
a.demo {
	padding: 3px;
	background-color: #2c798c;
	color: #fff;
}
.series {
	width: 100%;
	height: 135px;
}
.series,
.build {
	font-size: smaller;
	border: 1px solid #2c798c;
	background-color: #e5faff;
}
.series table,
.build table {
	margin: 0 7px;
	padding: 0 5px;
}
.series table {
	float: left;
	width: 110px;
}
.build table {
	margin: 0 auto;
}
.series td,
.series th,
.build td,
.build th {
	text-align: right;
}
.build td,
.build th {
	padding: 1px 5px;
}
.series table tr th, 
.build table tr th {
	border-bottom: 1px solid;
}
.series table.labels tr th {
	border-bottom: none;
	padding-bottom: 2px;
}
.series table.labels,
.series table caption,
.build table .label {
	color: #2c798c;
}
.series table .total {
	border-top-style: double;
	border-top-width: 3px;
}
.series table.labels .total {
	border-top-style: none;
}
.series table.labels .total td {
	padding-top: 4px;
}
.build th.label {
	border-bottom: none;
}
</style>
<p>SitePen&#8217;s <a href="http://dgrid.io/">dgrid</a> project leverages the AMD loader and other features new since Dojo 1.7 to minimize the load and rendering times of dynamic grids in web applications.  In this post, we conduct tests in four common scenarios for both dgrid and <a href="http://dojotoolkit.org/reference-guide/dojox/grid/DataGrid.html">DojoX DataGrid</a>, contrasting startup, render, and destroy times in several popular browsers.  We also discuss the amount of code involved in loading common components of dgrid and DojoX DataGrid.</p>
<p>The demos below test each grid in three phases:</p>
<ol>
<li><strong>Startup</strong> &#8211; the time required to create the instance of the grid, define the columns and any other configuration, and display the grid with headers but no data</li>
<li><strong>Render</strong> &#8211; the time required to process and present the first page of data in the grid (25 items); since both grids use lazy loading, render time for the first page is representative for all pages
<li><strong>Destroy</strong> &#8211; the time taken to remove the grid&#8217;s DOM from the document, and perform any internal cleanup</li>
</ol>
<p><span id="more-5919"></span><br />
In order to offer an accurate comparison, the following practices were established for each test:</p>
<ul>
<li>Both grids use identical data and are rendered in a space with the same dimensions on the page.  Since DojoX DataGrid only supports dojo/data stores, the <a href="http://dojotoolkit.org/reference-guide/dojo/data/ObjectStore.html">ObjectStore</a> module is used to wrap a Memory store.  This may slightly influence timing of render tests, but it is still a legitimate factor when comparing the two implementations.</li>
<li>The steps have been verified to ensure that both grids are in the same state at the end of each of the three steps, as described above.</li>
<li>Testing is done sequentially: first the dgrid is tested, then the DojoX DataGrid.</li>
<li>For each operation, the start time is noted, the actions are performed, and the elapsed time is calculated.  A total time is also included, representing the sum of the startup and render times, as the performance of these two operations combined is a common concern.</li>
<li>The time taken to load modules is not included in these performance comparisons.  Payload size is discussed later, in the context of built layers.</li>
<li>All tests were run on the same machine, running Windows 7, with the exception of IE8 testing, which was conducted within a Windows XP VM on that machine.  However, it is important to note that the objective of these tests is to compare the timings between the grid implementations on each browser, not necessarily to compare timings between browsers/platforms themselves.
</ul>
<p>All the demo pages are available for you to run, with the results displayed both on the page and in the browser console.  The startup, render, and destroy tests all run immediately in sequence, so it&#8217;s likely you won&#8217;t actually see the grids on the page.  However, the demo pages are also constructed such that you can easily copy the source code and pick apart the tests on your own Web server.</p>
<p>The first test is for a very basic grid.  A Memory store is created with simple items containing only a name and a unique id.  For a basic grid configured to only display the name field, the times to startup, render and destroy the grid are as follows:</p>
<div class="series">
<table class="labels">
<caption>&nbsp;</caption>
<tr>
<th>&nbsp;</th>
</tr>
<tr>
<td>Startup</td>
</tr>
<tr>
<td>Render</td>
</tr>
<tr class="total">
<td>Total</td>
</tr>
<tr>
<td>Destroy</td>
</tr>
</table>
<table>
<caption>Firefox 16</caption>
<tr>
<th>dgrid</th>
<th>DataGrid</th>
</tr>
<tr>
<td>8ms</td>
<td>24ms</td>
</tr>
<tr>
<td>24ms</td>
<td>50ms</td>
</tr>
<tr class="total">
<td>32ms</td>
<td>74ms</td>
</tr>
<tr>
<td>0ms</td>
<td>4ms</td>
</tr>
</table>
<table>
<caption>Chrome 23</caption>
<tr>
<th>dgrid</th>
<th>DataGrid</th>
</tr>
<tr>
<td>8ms</td>
<td>16ms</td>
</tr>
<tr>
<td>13ms</td>
<td>24ms</td>
</tr>
<tr class="total">
<td>21ms</td>
<td>40ms</td>
</tr>
<tr>
<td>0ms</td>
<td>2ms</td>
</tr>
</table>
<table>
<caption>Internet Explorer 9</caption>
<tr>
<th>dgrid</th>
<th>DataGrid</th>
</tr>
<tr>
<td>6ms</td>
<td>18ms</td>
</tr>
<tr>
<td>22ms</td>
<td>34ms</td>
</tr>
<tr class="total">
<td>28ms</td>
<td>52ms</td>
</tr>
<tr>
<td>1ms</td>
<td>2ms</td>
</tr>
</table>
<table>
<caption>Internet Explorer 8</caption>
<tr>
<th>dgrid</th>
<th>DataGrid</th>
</tr>
<tr>
<td>10ms</td>
<td>60ms</td>
</tr>
<tr>
<td>70ms</td>
<td>100ms</td>
</tr>
<tr class="total">
<td>80ms</td>
<td>160ms</td>
</tr>
<tr>
<td>0ms</td>
<td>10ms</td>
</tr>
</table>
</div>
<p><a class="demo" href="/labs/code/dgrid/blog/perfcomp/1.php">Run demo</a></p>
<p>Most grids include more columns and data.  The second demonstration uses a larger store with more complex items, rendered in 6 columns; the times to startup, render the first 25 rows, and destroy are as follows:</p>
<div class="series">
<table class="labels">
<caption>&nbsp;</caption>
<tr>
<th>&nbsp;</th>
</tr>
<tr>
<td>Startup</td>
</tr>
<tr>
<td>Render</td>
</tr>
<tr class="total">
<td>Total</td>
</tr>
<tr>
<td>Destroy</td>
</tr>
</table>
<table>
<caption>Firefox 16</caption>
<tr>
<th>dgrid</th>
<th>DataGrid</th>
</tr>
<tr>
<td>10ms</td>
<td>29ms</td>
</tr>
<tr>
<td>44ms</td>
<td>78ms</td>
</tr>
<tr class="total">
<td>54ms</td>
<td>107ms</td>
</tr>
<tr>
<td>1ms</td>
<td>4ms</td>
</tr>
</table>
<table>
<caption>Chrome 23</caption>
<tr>
<th>dgrid</th>
<th>DataGrid</th>
</tr>
<tr>
<td>9ms</td>
<td>19ms</td>
</tr>
<tr>
<td>39ms</td>
<td>48ms</td>
</tr>
<tr class="total">
<td>48ms</td>
<td>67ms</td>
</tr>
<tr>
<td>0ms</td>
<td>3ms</td>
</tr>
</table>
<table>
<caption>Internet Explorer 9</caption>
<tr>
<th>dgrid</th>
<th>DataGrid</th>
</tr>
<tr>
<td>6ms</td>
<td>17ms</td>
</tr>
<tr>
<td>60ms</td>
<td>57ms</td>
</tr>
<tr class="total">
<td>66ms</td>
<td>74ms</td>
</tr>
<tr>
<td>2ms</td>
<td>3ms</td>
</tr>
</table>
<table>
<caption>Internet Explorer 8</caption>
<tr>
<th>dgrid</th>
<th>DataGrid</th>
</tr>
<tr>
<td>10ms</td>
<td>50ms</td>
</tr>
<tr>
<td>170ms</td>
<td>160ms</td>
</tr>
<tr class="total">
<td>180ms</td>
<td>210ms</td>
</tr>
<tr>
<td>0ms</td>
<td>10ms</td>
</tr>
</table>
</div>
<p><a class="demo" href="/labs/code/dgrid/blog/perfcomp/2.php">Run demo</a></p>
<p><strong>Subrows</strong> can be used to further organize data such that each item&#8217;s data is presented across multiple table rows.  The results of tests using the same data as the previous example in a grid with subrows are as follows:</p>
<div class="series">
<table class="labels">
<caption>&nbsp;</caption>
<tr>
<th>&nbsp;</th>
</tr>
<tr>
<td>Startup</td>
</tr>
<tr>
<td>Render</td>
</tr>
<tr class="total">
<td>Total</td>
</tr>
<tr>
<td>Destroy</td>
</tr>
</table>
<table>
<caption>Firefox 16</caption>
<tr>
<th>dgrid</th>
<th>DataGrid</th>
</tr>
<tr>
<td>10ms</td>
<td>26ms</td>
</tr>
<tr>
<td>47ms</td>
<td>77ms</td>
<tr class="total">
<td>57ms</td>
<td>103ms</td>
<tr>
<td>1ms</td>
<td>4ms</td>
</tr>
</table>
<table>
<caption>Chrome 23</caption>
<tr>
<th>dgrid</th>
<th>DataGrid</th>
</tr>
<tr>
<td>9ms</td>
<td>19ms</td>
</tr>
<tr>
<td>40ms</td>
<td>47ms</td>
</tr>
<tr class="total">
<td>49ms</td>
<td>66ms</td>
</tr>
<tr>
<td>1ms</td>
<td>2ms</td>
</tr>
</table>
<table>
<caption>Internet Explorer 9</caption>
<tr>
<th>dgrid</th>
<th>DataGrid</th>
</tr>
<tr>
<td>6ms</td>
<td>23ms</td>
</tr>
<tr>
<td>62ms</td>
<td>62ms</td>
</tr>
<tr class="total">
<td>68ms</td>
<td>85ms</td>
</tr>
<tr>
<td>2ms</td>
<td>4ms</td>
</tr>
</table>
<table>
<caption>Internet Explorer 8</caption>
<tr>
<th>dgrid</th>
<th>DataGrid</th>
</tr>
<tr>
<td>10ms</td>
<td>70ms</td>
</tr>
<tr>
<td>140ms</td>
<td>130ms</td>
</tr>
</tr>
<tr class="total">
<td>150ms</td>
<td>200ms</td>
</tr>
</tr>
<tr>
<td>0ms</td>
<td>10ms</td>
</tr>
</table>
</div>
<p><a class="demo" href="/labs/code/dgrid/blog/perfcomp/3.php">Run demo</a></p>
<p><strong>ColumnSets</strong> (known as <em>Views</em> in the DojoX DataGrid) allow for even more complex organization of data.  In addition to supporting subrows, they also support arranging data into sets of columns with independent horizontal scrolling.  The results of tests using the same data as the previous example in a grid with two columnsets/views are as follows:</p>
<div class="series">
<table class="labels">
<caption>&nbsp;</caption>
<tr>
<th>&nbsp;</th>
</tr>
<tr>
<td>Startup</td>
</tr>
<tr>
<td>Render</td>
</tr>
<tr class="total">
<td>Total</td>
</tr>
<tr>
<td>Destroy</td>
</tr>
</table>
<table>
<caption>Firefox 16</caption>
<tr>
<th>dgrid</th>
<th>DataGrid</th>
</tr>
<tr>
<td>16ms</td>
<td>36ms</td>
</tr>
<tr>
<td>67ms</td>
<td>135ms</td>
</tr>
<tr class="total">
<td>83ms</td>
<td>171ms</td>
</tr>
<tr>
<td>1ms</td>
<td>5ms</td>
</tr>
</table>
<table>
<caption>Chrome 23</caption>
<tr>
<th>dgrid</th>
<th>DataGrid</th>
</tr>
<tr>
<td>10ms</td>
<td>22ms</td>
</tr>
<tr>
<td>56ms</td>
<td>73ms</td>
</tr>
<tr class="total">
<td>66ms</td>
<td>95ms</td>
</tr>
<tr>
<td>2ms</td>
<td>4ms</td>
</tr>
</table>
<table>
<caption>Internet Explorer 9</caption>
<tr>
<th>dgrid</th>
<th>DataGrid</th>
</tr>
<tr>
<td>9ms</td>
<td>23ms</td>
</tr>
<tr>
<td>98ms</td>
<td>101ms</td>
</tr>
<tr class="total">
<td>107ms</td>
<td>124ms</td>
</tr>
<tr>
<td>3ms</td>
<td>5ms</td>
</tr>
</table>
<table>
<caption>Internet Explorer 8</caption>
<tr>
<th>dgrid</th>
<th>DataGrid</th>
</tr>
<tr>
<td>10ms</td>
<td>60ms</td>
</tr>
<tr>
<td>271ms</td>
<td>310ms</td>
</tr>
<tr class="total">
<td>281ms</td>
<td>370ms</td>
</tr>
<tr>
<td>10ms</td>
<td>20ms</td>
</tr>
</table>
</div>
<p><a class="demo" href="/labs/code/dgrid/blog/perfcomp/4.php">Run demo</a></p>
<p>From the tests above, although results vary across browsers, we can easily conclude that dgrid shows the most significant advantage in terms of startup and destroy times, which are consistently over twice as fast as the startup times of the DojoX DataGrid.  The relation between render times ranges between staying on par between the two implementations, and being up to twice as fast on modern browsers, especially in simple scenarios.</p>
<p>However, the results above reflect only the processing time through stages of the grids&#8217; lifecycles.  It is also important to consider the time and bandwidth required to load the necessary modules.  The architecture of dgrid leaves it up to the developer to choose which mixins, column plug-ins, extensions, and utilities to load.  On the other hand, DataGrid includes more functionality by default, which requires loading more code and performing more initial setup.</p>
<p>In a production environment, code for any modules used in an application should be built into layers using Dojo&#8217;s build system.  The table below lists the size (in bytes) of the built code for layers containing the following modules and their dependencies:</p>
<ul>
<li>dgrid&#8217;s OnDemandGrid</li>
<li>OnDemandGrid plus features equivalent to those DataGrid includes by default (namely the Keyboard, Selection, and ColumnSet mixins, as well as the ColumnReorder and ColumnResizer extensions)</li>
<li>DojoX DataGrid</li>
</ul>
<div class="build">
<table>
<tr>
<th class="label">&nbsp;</th>
<th>dgrid</th>
<th>dgrid + features</th>
<th>DataGrid</th>
</tr>
<tr>
<td class="label">Minified</td>
<td>53,524</td>
<td>129,080</td>
<td>264,522</td>
</tr>
<tr>
<td class="label">Minified + GZipped</td>
<td>18,815</td>
<td>42,597</td>
<td>80,707</td>
</tr>
</table>
</div>
<p>For additional information about performing custom builds with dgrid, refer to our previous post on <a href="http://www.sitepen.com/blog/2012/06/11/dgrid-and-dojo-nano-build/">dgrid and Dojo&#8217;s nano build</a>.</p>
<p>Bear in mind the objective of this post and these tests is to compare dgrid and DataGrid as accurately as possible, not the browsers or versions.  You may wish to conduct additional tests with tools such as <a href="http://www.broofa.com/Tools/JSLitmus/">JSLitmus</a> or <a href="http://benchmarkjs.com/">benchmark.js</a>.</p>
<h3>Conclusion</h3>
<p>dgrid performs more efficiently than DataGrid, which was one of the primary goals in its design.  In addition, its modern architecture allows it to be easily extended and serve as a foundation for a wide variety of UI applications.</p>
<p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sitepen.com/blog/2013/01/24/performance-comparison-dgrid-ondemandgrid-and-dojo-grid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generating and Viewing Custom Dojo API Documentation</title>
		<link>http://www.sitepen.com/blog/2013/01/18/generating-and-viewing-custom-api-docs/</link>
		<comments>http://www.sitepen.com/blog/2013/01/18/generating-and-viewing-custom-api-docs/#comments</comments>
		<pubDate>Fri, 18 Jan 2013 07:30:22 +0000</pubDate>
		<dc:creator>Paul Bouchon</dc:creator>
				<category><![CDATA[api]]></category>
		<category><![CDATA[docs]]></category>
		<category><![CDATA[Dojo]]></category>
		<category><![CDATA[featured]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[dojo 1.8]]></category>

		<guid isPermaLink="false">http://www.sitepen.com/blog/?p=6167</guid>
		<description><![CDATA[<p>When developing a JavaScript framework that others will consume, it&#8217;s hugely beneficial to provide clean, organized API documentation to accompany your codebase. With the August release of Dojo 1.8, we saw a brand new, extensible documentation parser, which is used to generate output for Dojo&#8217;s API viewer. Generating documentation for any project and serving up [...]</p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></description>
				<content:encoded><![CDATA[<p>
When developing a JavaScript framework that others will consume, it&#8217;s hugely beneficial to provide clean, organized API documentation to accompany your codebase.  With the <a href="http://dojotoolkit.org/blog/dojo-1-8-released">August release of Dojo 1.8</a>, we saw a brand new, extensible documentation parser, which is used to generate output for <a href="http://dojotoolkit.org/api/">Dojo&#8217;s API viewer</a>. Generating documentation for any project and serving up a custom API viewer is easy, and this post will show you exactly how to do it.
</p>
<p><span id="more-6167"></span></p>
<h3>Dojo Markup Syntax</h3>
<p>
Any project wishing to take advantage of the API generation tools should comment their code using Dojo&#8217;s Inline Documentation syntax &#8211; a straightforward set of commenting conventions that allow for easy documentation parsing. This is analogous to Javadoc and other similar conventions used in most programming languages today. For example:
</p>
<pre lang="javascript">
// summary:
//            This is the summary for the method.
//            It's indented by two tabs.
// foo: Integer
//            First argument to this function
// bar: String
//            Second argument to this function
// returns:
//            A calculated value.
</pre>
<p>
When parsing a comment block, the parser searches for a specific list of words or &#8220;keys&#8221;, including <em>summary</em>, <em>description</em>, <em>this</em>, and <em>returns</em>. Custom object properties and function parameters can also be documented using the same key-value comment format, as shown in the snippet above. Several other options are also supported, check out the full <a href="http://dojotoolkit.org/reference-guide/1.8/developer/markup.html#developer-markup">documentation for Dojo&#8217;s inline markup</a> for more details.
</p>
<h3>Generating the docs</h3>
<p>
The Dojo team has worked hard to ensure that the actual generation of the docs was as simple as possible to configure and run.  Before proceeding, make sure you have <a href="http://www.apache.org/dyn/closer.cgi">apache</a>, <a href="http://nodejs.org/">node.js</a>, and <a href="http://php.net/downloads.php">php 5.2 or greater</a> installed. Next, it&#8217;s just three simple steps to generate shiny new API documentation:
</p>
<ol>
<li>Clone js-doc-parse.</li>
<p><pre lang="bash">
$ git clone --recursive https://github.com/wkeese/js-doc-parse.git
$ cd js-doc-parse
$ git checkout all-my-changes
</pre>
</p>
<li>Edit environmentConfig object in <code>config.js</code>.</li>
<p>
This tells the parser where your project is located. <code>basePath</code> should indicate the path to your project relative to <code>config.js</code>, and package paths should be relative to the <code>basePath</code>. </p>
<pre lang="javascript">
environmentConfig: {
    basePath: '../some/path/',
    packages: {
        myApp: 'myApp'
    }
}
</pre>
<p><em>Note: other configuration options exist in <code>config.js</code>.</em>
</p>
<li>Parse like there&#8217;s no tomorrow.</li>
<p>
The output will consist of the <code>details.xml</code> and <code>tree.json</code> files within the js-doc-parse folder.</p>
<pre lang="bash">
$ ./parse.sh ../some/path/myApp
</pre>
</p>
</ol>
<p>
That&#8217;s it! The documentation for your custom project has officially been generated. But how do we see it?
</p>
<h3>Viewing the docs</h3>
<p>
Now that the documentation has been successfully generated, all that&#8217;s left is to grab the API viewer in order to view the docs locally.
</p>
<ol>
<li>Clone api-viewer.</li>
<p><pre lang="bash">
$ cd <web_server_root>
$ git clone git@github.com:wkeese/api-viewer.git api
</pre>
<p><em>Note: If you want to put the API viewer in a location other than your server root,  config.php and .htaccess need to be updated to point to the other location.</em>
</p>
<li>Move generated files.</li>
<p>
We need to put the generated <code>details.xml</code> and <code>tree.json</code> in a location so the API viewer can find them. The viewer expects an <code>api_data/</code> folder as its <strong>sibling</strong> with subfolders corresponding to project version numbers.</p>
<pre lang="bash">
$ cd <web_server_root>
$ mkdir api_data/
$ mkdir api_data/1.0
$ mv js-doc-parse/details.xml api_data/1.0/
$ mv js-doc-parse/tree.json api_data/1.0/
$ chmod -R +a 'user:_www allow delete,list,search,add_file,add_subdirectory,read,write' api_data
</pre>
</p>
</ol>
<p>
Finally, start your local Apache instance and point your browser to <a href="http://localhost/api/">http://localhost/api/</a>.
</p>
<h3>Theming the docs</h3>
<p>
Many users have asked how to modify the default theming of the API viewer itself. The styles and static content are broken down into a few key files that can easily be customized to fit your style needs, each of which will be included as the pages are generated.
</p>
<ul>
<li><strong>theme.css</strong> &#8211; Includes any CSS styling that needs to be included in the document</li>
<li><strong>index.php</strong> &#8211; Populates the Welcome tab of the API Viewer</li>
<li><strong>header.php</strong> &#8211; Inserted before the main content area</li>
<li><strong>footer.php</strong> &#8211; Inserted after the main content area</li>
</ul>
<h3>Conclusion</h3>
<p>
Rather than simply generating an endless page of formatted API documentation, Dojo&#8217;s documentation tools provide a clean, simple method to produce an enterprise-quality API viewer and documentation for any JavaScript project. While more advanced configuration options for generation and viewing are available, the above guide should get any project up and running with their very own API viewer.</p>
<p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sitepen.com/blog/2013/01/18/generating-and-viewing-custom-api-docs/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
