<?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 &#187; support</title>
	<atom:link href="http://www.sitepen.com/blog/tag/support-2/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, 22 May 2013 22:36:10 +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>Working with Dojo and AMD in Production</title>
		<link>http://www.sitepen.com/blog/2012/08/27/working-with-dojo-and-amd-in-production/</link>
		<comments>http://www.sitepen.com/blog/2012/08/27/working-with-dojo-and-amd-in-production/#comments</comments>
		<pubDate>Mon, 27 Aug 2012 13:17:33 +0000</pubDate>
		<dc:creator>Dylan Schiemann</dc:creator>
				<category><![CDATA[AMD]]></category>
		<category><![CDATA[dgrid]]></category>
		<category><![CDATA[Dojo]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Support]]></category>
		<category><![CDATA[amd]]></category>
		<category><![CDATA[amdjs]]></category>
		<category><![CDATA[support]]></category>

		<guid isPermaLink="false">http://www.sitepen.com/blog/?p=5040</guid>
		<description><![CDATA[<p>In our recent post on dgrid and Dojo Nano, we showed a technique of using nested require statements in order to make use of optimized layers using the Dojo build system. As a refresher, a layer is Dojo&#8217;s terminology for a file that combines many JavaScript resources into a single file. This improves the performance [...]</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>In our recent post on <a href="http://www.sitepen.com/blog/2012/06/11/dgrid-and-dojo-nano-build/">dgrid and Dojo Nano</a>, we showed a technique of using nested require statements in order to make use of optimized layers using the Dojo build system. As a refresher, a layer is Dojo&#8217;s terminology for a file that combines many JavaScript resources into a single file. This improves the performance of your web application by minimizing the number of HTTP requests.</p>
<p>The technique we originally presented was a quick and simple approach:</p>
<pre lang="html">&lt;script type="text/javascript" src="../../dojo/dojo.js"
	data-dojo-config="async: true"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
	require(['dgrid/dgrid'], function () {
	    require(["dgrid/List", "dgrid/OnDemandGrid","dgrid/Selection", 
		"dgrid/Keyboard", "dojo/_base/declare", "dgrid/test/data/perf", 
		"dojo/domReady!"],
		function(List, Grid, Selection, Keyboard, declare, testPerfStore){
		//...
</pre>
<p>While this works, it&#8217;s not ideal because you will need to modify your source when switching between development and production environments which is suboptimal. While you could of course fix this with PHP or some other server-side approach for your initial require statement, there are many simple alternative techniques that you can make directly to your markup. Here we explore five other approaches.</p>
<p><span id="more-5040"></span></p>
<h2>Single-layer builds</h2>
<h3>Ideal for: A quick, simple, single-layer application</h3>
<p>In the original blog post, we focused on building simple nano and baseless builds. In this scenario, you may want to just create a custom dojo.js to include all modules that you need. Then we just have the main <code>require()</code> statement with all the <code>dgrid</code> modules. We don&#8217;t need to <code>require()</code> calls to the layer in advance, since the <code>dgrid</code> modules would already be loaded from dojo.js in production. The <code>require()</code> call would just immediately callback since everything the application needs has already loaded.</p>
<h2>Defining a different require module based on the URL</h2>
<h3>Ideal for: Quick and simple approach to loading based on the URL format</h3>
<p>This approach evaluates the application&#8217;s dependencies as a function of the URL. For example, we could test for the word dev in the URL, and only define a dependency on the built dgrid layer when not in a development environment:</p>
<pre lang="javascript">
require(/dev/.test(location.search) ? [] : ['dgrid/dgrid'], function(){
	require(["dgrid/List", "dgrid/OnDemandGrid","dgrid/Selection", 
		"dgrid/Keyboard", "dojo/_base/declare", "dgrid/test/data/perf", 
		"dojo/domReady!"],
		function(List, Grid, Selection, Keyboard, declare, testPerfStore){
		//...
	});
});
</pre>
<h2>Configuring layers with <code>deps</code> and <code>callback</code></h2>
<h3>Ideal for: Handling the differences between development and production based on URL or other settings within the dojoConfig object</h3>
<p>Dojo&#8217;s configuration settings allow you to use <code>dojoConfig.deps</code> to load the layer and <code>dojoConfig.callback</code> to start an application:</p>
<pre lang="html" class="highlight:[5,6]">&lt;script type="text/javascript"&gt;
var dojoConfig = {
	async: 1,
	deps: ['dgrid/dgrid'],
	callback: function(){
		require(["dgrid/List", "dgrid/OnDemandGrid","dgrid/Selection", 
			"dgrid/Keyboard", "dojo/_base/declare", "dgrid/test/data/perf", 
			"dojo/domReady!"],
			function(List, Grid, Selection, Keyboard, declare, testPerfStore){
			//...
		});
	}
};
&lt;/script&gt;
&lt;/script type="text/javascript" src="../../dojo/dojo.js"&gt;&lt;/script&gt;
</pre>
<p>When the defined dependencies have loaded, a callback function is executed, all of which is defined within the configuration object. We can now evaluate the application&#8217;s dependencies as a function of the URL, similar to the previous example, and then handle the check in the <code>dojoConfig</code> object rather than within a require statement :</p>
<pre lang="html" class="highlight:[4]">&lt;script&gt;
var dojoConfig = {
	async: 1,
	deps: /dev/.test(location.search) ? [] : ['dgrid/dgrid'],
	callback: function(){
		require(["dgrid/List", "dgrid/OnDemandGrid","dgrid/Selection", 
			"dgrid/Keyboard", "dojo/_base/declare", "dgrid/test/data/perf", 
			"dojo/domReady!"],
			function(List, Grid, Selection, Keyboard, declare, testPerfStore){
			//...
		});
	}
};
&lt;/script&gt;
&lt;/script type="text/javascript" src="../../dojo/dojo.js"&gt;&lt;/script&gt;
</pre>
<p>This allows us to vary <code>dojoConfig.deps</code> on a flexible switch. It could be the URL, or a single variable defined at the top of the application&#8217;s markup. We can also define dependencies as a function, with more elaborate criteria for defining the dependencies to load for the application.</p>
<p>The flexibility of this technique makes moving between development, test, and production environments simple and efficient.</p>
<h2>Top level modules</h2>
<h3>Idea for: Larger applications with many dependencies</h3>
<p>Another common approach for a smooth transition between development and production is to create a single top level module per layer that loads all the other modules each application uses. Then the Dojo build tool can be given a single module per layer to create a layer of the same name, so that development and production both load the entry module, as a single dependency in the HTML. This has the added benefit of keeping JavaScript out of your HTML, particularly your dependencies, so you can have a JavaScript-free HTML file.</p>
<p>For example, you might have a file, app/app.js:</p>
<pre lang="javascript">
define(["dgrid/List", "dgrid/OnDemandGrid","dgrid/Selection", "dgrid/Keyboard",
    "dojo/_base/declare", "dgrid/test/data/perf", "dojo/domReady!"],
    function(List, Grid, Selection, Keyboard, declare, testPerfStore){
        //...
});
</pre>
<p>And then, your HTML file would simply contain the following fragment:</p>
<pre lang="html" class="highlight:[4]">&lt;script&gt;
var dojoConfig = {
	async: true,
	deps: ["app/app"]
};
&lt;/script&gt;
&lt;script src="dojo/dojo.js"&gt;&lt;/script&gt;
</pre>
<h2>Dojo Boilerplate</h2>
<h3>Ideal for: Mostly automated approach to following many Dojo best practices for building apps</h3>
<p>The <a href="https://github.com/csnover/dojo-boilerplate">Dojo Boilerplate</a> project will handle this scenario for you automatically. It identifies a few <a href="https://github.com/csnover/dojo-boilerplate#a-brief-tour">Dojo application architecture conventions to follow</a>, and then contains a build script that assists when moving from development to production.</p>
<h2>Conclusion</h2>
<p>As you can see, there are many approaches to simplify your approach for working with Dojo layers in production when using AMD. Let us know in the comments if you have another technique you prefer, or if you have any questions.</p>
<h2>References</h2>
<ul>
<li><a href="http://dojotoolkit.org/reference-guide/1.8/loader/amd.html">Dojo loader reference docs, including details about deps and callback</a></li>
<li><a href="http://dojotoolkit.org/api/1.8/dojo/_base/config">API docs for dojoConfig</a></li>
<li><a href="https://github.com/csnover/dojo-boilerplate">Dojo Boilerplate</a></li>
</ul>
<h2>Help for your application</h2>
<p><a href="http://www.sitepen.com/site/contact.html">Contact us</a> for more information on how we can help you migrate your application to fully leverage AMD. Or, check out our excellent <a href="http://www.sitepen.com/support/index.html">Dojo and JavaScript support services</a>, which can be utilized for working on any AMD-based development project.</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/2012/08/27/working-with-dojo-and-amd-in-production/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Now Supporting all Major Toolkits!</title>
		<link>http://www.sitepen.com/blog/2012/07/19/now-supporting-all-major-toolkits/</link>
		<comments>http://www.sitepen.com/blog/2012/07/19/now-supporting-all-major-toolkits/#comments</comments>
		<pubDate>Thu, 19 Jul 2012 15:20:25 +0000</pubDate>
		<dc:creator>Dylan Schiemann</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[AMD]]></category>
		<category><![CDATA[Cometd]]></category>
		<category><![CDATA[CommonJS]]></category>
		<category><![CDATA[dgrid]]></category>
		<category><![CDATA[Dojo]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Node.js]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Persevere]]></category>
		<category><![CDATA[Support]]></category>
		<category><![CDATA[backbone]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[mootools]]></category>
		<category><![CDATA[nodejs]]></category>
		<category><![CDATA[support]]></category>

		<guid isPermaLink="false">http://www.sitepen.com/blog/?p=4951</guid>
		<description><![CDATA[<p>We have been providing JavaScript and Dojo support to freelancers, start-ups and Fortune 500 companies for nearly a decade. As we intently watch enterprise organizations everywhere begin to roll out AMD (read about why AMD matters) and the associated code improvements, we are thrilled with the industry&#8217;s direction toward toolkit interoperability! Why? Because! Our masterful [...]</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 have been providing JavaScript and Dojo support to freelancers, start-ups and Fortune 500 companies for nearly a decade.  As we intently watch enterprise organizations everywhere begin to roll out AMD <a href="http://www.sitepen.com/blog/2012/07/10/amd-for-the-business-side/">(read about why AMD matters)</a> and the associated code improvements, we are thrilled with the industry&#8217;s direction toward toolkit interoperability!  Why?  Because! Our masterful engineering team, consisting of influential members of various open source communities, positions SitePen perfectly to offer full-on, front-end web development support to the world! </p>
<p>Getting right to the point, (<a href="http://www.prnewswire.com/news-releases/sitepen-expands-service-offering-to-popular-javascript-toolkits-163018596.html">The Official Point!</a>), we are pleased to announce the expansion of SitePen Support to officially include more than fifteen popular open-source JavaScript toolkits! </p>
<p><strong>Now supporting the following JavaScript toolkits:</strong></p>
<table style="width:600px;">
<tr>
<td>
<ul>
<li>Dojo</li>
<li>Persevere packages</li>
<li>dgrid</li>
<li>Curl.js</li>
<li>CometD</li>
<li>Twine</li>
</ul>
</td>
<td>
<ul>
<li>jQuery</li>
<li>Backbone</li>
<li>underscore</li>
<li>RequireJS</li>
<li>PhoneGap/Cordova</li>
<li>MooTools</li>
</ul>
</td>
<td>
<ul>
<li>jQueryUI</li>
<li>Wire</li>
<li>Socket.IO</li>
<li>Express</li>
</ul>
</td>
</tr>
</table>
<p>In addition to toolkits, we will continue to support your custom JavaScript source code, as well as key underlying technologies and formats, including JSON, HTML5, WebSockets, SVG/Canvas, Mobile Web, Server-Side JavaScript, AMD, Node.js and many more.</p>
<p>Our expertise with Dojo and advanced JavaScript is relevant for a wide-range of desktop and mobile web application projects and our approach to SitePen Support has always been flexible with the priority being to improve our customers&#8217; web apps.  We strive to support our customers in every way possible and we continue to be Dojo experts. In addition, we&#8217;re now committed to providing your organization with the front-end development expertise that will optimize your application regardless of which toolkits and technologies your company is comfortable using.  You have our word!</p>
<p>Learn More About <a href="http://www.sitepen.com/support/index.html">SitePen Support</a> or <a href="http://www.sitepen.com/site/contact.html">Contact Us </a>to get started today!</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/2012/07/19/now-supporting-all-major-toolkits/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
