<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" version="2.0"><channel><title>Dan Wahlin's WebLog</title><link>http://weblogs.asp.net/dwahlin/default.aspx</link><description>jQuery, HTML5, JavaScript, ASP.NET, and XAML</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/dwahlin" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="dwahlin" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item><title>jQuery Tip #2 - Manipulating the DOM in a Loop</title><link>http://weblogs.asp.net/dwahlin/archive/2012/02/08/jquery-tip-2-manipulating-the-dom-in-a-loop.aspx</link><pubDate>Thu, 09 Feb 2012 06:22:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8290248</guid><dc:creator>dwahlin</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=8290248</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2012/02/08/jquery-tip-2-manipulating-the-dom-in-a-loop.aspx#comments</comments><description>&lt;p&gt;One of jQuery's greatest strengths is its ability to manipulate the DOM with a minimal amount of code. It's so easy to change things that we often don't think about what's happening under the covers. For example, consider the following code that appends nodes to an object named parentDiv.&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;    &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;parentDiv = $(&lt;span style="color: maroon"&gt;'#emailList'&lt;/span&gt;);
&lt;span style="color: blue"&gt;for &lt;/span&gt;(&lt;span style="color: blue"&gt;var &lt;/span&gt;i = 0; i &amp;lt; 100; i++) {
    parentDiv.append(&lt;span style="color: maroon"&gt;'&amp;lt;div&amp;gt;' &lt;/span&gt;+ i + &lt;span style="color: maroon"&gt;'&amp;lt;/div&amp;gt;'&lt;/span&gt;);
}&lt;br /&gt;&lt;/pre&gt;
  &lt;/p&gt;

&lt;p&gt;This is one of the more common ways to append nodes into a given parent. Although it works fine, it's not optimal because jQuery has to constantly perform DOM operations in the loop. You may not notice a problem when looping through 100 items, but as that number increases to a larger number the performance can start to degrade. A more efficient (yet simple) approach from a performance standpoint is shown next:&lt;/p&gt;

&lt;p&gt;
  &lt;br /&gt;

  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;parentDiv = $(&lt;span style="color: maroon"&gt;'#emailList'&lt;/span&gt;);
&lt;span style="color: blue"&gt;var &lt;/span&gt;divs = &lt;span style="color: maroon"&gt;''&lt;/span&gt;;
&lt;span style="color: blue"&gt;for &lt;/span&gt;(&lt;span style="color: blue"&gt;var &lt;/span&gt;i = 0; i &amp;lt; 100; i++) {
  divs += &lt;span style="color: maroon"&gt;'&amp;lt;div&amp;gt;' &lt;/span&gt;+ i + &lt;span style="color: maroon"&gt;'&amp;lt;/div&amp;gt;'&lt;/span&gt;;
}
parentDiv.html(divs);&lt;br /&gt;&lt;/pre&gt;
  &lt;/p&gt;

&lt;p&gt;The previous code only touches the DOM once after the loop has completed resulting in better overall performance. While a lot of string concatenation is occurring, it turns out that going that route is much more efficient than calling append() multiple times. &lt;/p&gt;

&lt;p&gt;Keep in mind that you can always manipulate the DOM directly as well and increase performance even more in some cases by using things like document.createDocumentFragment() and other techniques. While I prefer to use jQuery functions whenever possible, sometimes it's necessary to step outside of jQuery’s API for a given task and use the native DOM API instead. &lt;/p&gt;

&lt;p&gt;A test page available at &lt;a href="http://jsperf.com/strings-vs-array-join-vs-doc-fragment/8"&gt;http://jsperf.com/strings-vs-array-join-vs-doc-fragment/8&lt;/a&gt; shows different techniques that can be used for updating the DOM while using a loop as well as their individual performance results. An example of the test results and the different techniques tested are shown next. You’ll notice that calling jQuery’s append() function in a loop doesn’t fare too well compared to some of the other more “native” DOM options.

  &lt;br /&gt;&lt;/p&gt;

&lt;table style="border-collapse: collapse; margin-bottom: 16px" id="test-table" width="960"&gt;&lt;thead style="margin-bottom: 16px"&gt;
    &lt;tr style="margin-bottom: 16px"&gt;
      &lt;th style="border-bottom-color: ; padding-bottom: 3px; background-color: rgb(26,106,185); padding-left: 8px; padding-right: 8px; border-bottom-width: 0px; color: ; padding-top: 3px; background-origin: initial; background-clip: initial" colspan="2" align="center"&gt;&lt;font face="Times New Roman"&gt;&lt;font style="font-size: 12pt" color="#ffffff"&gt;Test&lt;/font&gt;&lt;/font&gt;&lt;/th&gt;

      &lt;th style="border-bottom-color: ; padding-bottom: 3px; background-color: rgb(26,106,185); padding-left: 8px; padding-right: 8px; border-bottom-width: 0px; color: ; padding-top: 3px; background-origin: initial; background-clip: initial" title="Operations per second (higher is better)" align="center"&gt;&lt;font face="Times New Roman"&gt;&lt;font style="font-size: 12pt" color="#ffffff"&gt;Ops/sec&lt;/font&gt;&lt;/font&gt;&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;&lt;tbody style="margin-bottom: 16px"&gt;
    &lt;tr style="margin-bottom: 16px"&gt;
      &lt;th style="border-bottom: rgb(180,180,180) 1px solid; min-width: 100px; border-left: rgb(180,180,180) 0px solid; padding-bottom: 3px; background-color: rgb(221,228,234); padding-left: 8px; padding-right: 8px; border-top: rgb(180,180,180) 0px solid; border-right: rgb(180,180,180) 1px solid; padding-top: 3px; background-origin: initial; background-clip: initial; border-image: initial" id="title-1" title="Click to run this test again." tabindex="tabindex" scope="row" align="center"&gt;
        &lt;div style="overflow-x: auto; overflow-y: auto; max-width: 200px; word-wrap: break-word"&gt;&lt;font face="Times New Roman"&gt;&lt;font style="font-size: 12pt"&gt;Strings&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;
      &lt;/th&gt;

      &lt;td style="border-bottom: rgb(180,180,180) 1px solid; border-left: rgb(180,180,180) 0px solid; padding-bottom: 3px; background-color: transparent; padding-left: 8px; padding-right: 8px; border-top: rgb(180,180,180) 0px solid; border-right: rgb(180,180,180) 1px solid; padding-top: 3px; border-image: initial" class="code" width="650"&gt;
        &lt;pre style="overflow-x: auto; overflow-y: auto; width: 650px; word-wrap: break-word; white-space: pre-wrap"&gt;&lt;code style="font-family: "&gt;&lt;span style="color: " class="kw2"&gt;&lt;font color="#003366"&gt;var&lt;/font&gt;&lt;/span&gt; str &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="st0"&gt;&lt;font color="#3366cc"&gt;''&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: " class="kw2"&gt;&lt;font color="#003366"&gt;var&lt;/font&gt;&lt;/span&gt; c &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="st0"&gt;&lt;font color="#3366cc"&gt;'&amp;lt;li&amp;gt;'&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;+&lt;/font&gt;&lt;/span&gt; d.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;first&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;+&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="st0"&gt;&lt;font color="#3366cc"&gt;' '&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;+&lt;/font&gt;&lt;/span&gt; d.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;second&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;+&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="st0"&gt;&lt;font color="#3366cc"&gt;'&amp;lt;/li&amp;gt;'&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: " class="kw1"&gt;&lt;font color="#000066"&gt;for&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="kw2"&gt;&lt;font color="#003366"&gt;var&lt;/font&gt;&lt;/span&gt; i &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="nu0"&gt;&lt;font color="#cc0000"&gt;0&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt; i &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="nu0"&gt;&lt;font color="#cc0000"&gt;100&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt; i&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;++&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;)&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;{&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; str &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;+=&lt;/font&gt;&lt;/span&gt; c&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;}&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;document.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;getElementById&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="st0"&gt;&lt;font color="#3366cc"&gt;'list'&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;)&lt;/font&gt;&lt;/span&gt;.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;innerHTML&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; str&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
      &lt;/td&gt;

      &lt;td style="border-bottom: rgb(180,180,180) 1px solid; border-left: rgb(180,180,180) 0px solid; padding-bottom: 3px; border-right-width: 0px; padding-left: 8px; padding-right: 8px; border-right-color: ; border-top: rgb(180,180,180) 0px solid; padding-top: 3px; border-image: initial" id="results-1" class="results" title="Ran 70 times in 0.057 seconds." width="100" align="center"&gt;&lt;font style="font-size: 12pt" face="Times New Roman"&gt;1,226&lt;/font&gt;&lt;small style="display: block"&gt;&lt;font face="Times New Roman"&gt;&lt;font style="font-size: 9.6pt"&gt;±0.84%&lt;/font&gt;&lt;/font&gt;&lt;/small&gt;&lt;span style="display: block"&gt;&lt;font face="Times New Roman"&gt;&lt;font style="font-size: 9.6pt"&gt;61% slower&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr style="margin-bottom: 16px"&gt;
      &lt;th style="border-bottom: rgb(180,180,180) 1px solid; min-width: 100px; border-left: rgb(180,180,180) 0px solid; padding-bottom: 3px; background-color: rgb(221,228,234); padding-left: 8px; padding-right: 8px; border-top: rgb(180,180,180) 0px solid; border-right: rgb(180,180,180) 1px solid; padding-top: 3px; background-origin: initial; background-clip: initial; border-image: initial" id="title-2" title="Click to run this test again." tabindex="tabindex" scope="row" align="center"&gt;
        &lt;div style="overflow-x: auto; overflow-y: auto; max-width: 200px; word-wrap: break-word"&gt;&lt;font face="Times New Roman"&gt;&lt;font style="font-size: 12pt"&gt;Array (using push)&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;
      &lt;/th&gt;

      &lt;td style="border-bottom: rgb(180,180,180) 1px solid; border-left: rgb(180,180,180) 0px solid; padding-bottom: 3px; background-color: transparent; padding-left: 8px; padding-right: 8px; border-top: rgb(180,180,180) 0px solid; border-right: rgb(180,180,180) 1px solid; padding-top: 3px; border-image: initial" class="code" width="650"&gt;
        &lt;pre style="overflow-x: auto; overflow-y: auto; width: 650px; word-wrap: break-word; white-space: pre-wrap"&gt;&lt;code style="font-family: "&gt;&lt;span style="color: " class="kw2"&gt;&lt;font color="#003366"&gt;var&lt;/font&gt;&lt;/span&gt; arr &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; &lt;font color="#009900"&gt;&lt;span style="color: " class="br0"&gt;[&lt;/span&gt;&lt;span style="color: " class="br0"&gt;]&lt;/span&gt;&lt;/font&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: " class="kw2"&gt;&lt;font color="#003366"&gt;var&lt;/font&gt;&lt;/span&gt; c &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="st0"&gt;&lt;font color="#3366cc"&gt;'&amp;lt;li&amp;gt;'&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;+&lt;/font&gt;&lt;/span&gt; d.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;first&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;+&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="st0"&gt;&lt;font color="#3366cc"&gt;' '&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;+&lt;/font&gt;&lt;/span&gt; d.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;second&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;+&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="st0"&gt;&lt;font color="#3366cc"&gt;'&amp;lt;/li&amp;gt;'&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: " class="kw1"&gt;&lt;font color="#000066"&gt;for&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="kw2"&gt;&lt;font color="#003366"&gt;var&lt;/font&gt;&lt;/span&gt; i &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="nu0"&gt;&lt;font color="#cc0000"&gt;0&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt; i &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="nu0"&gt;&lt;font color="#cc0000"&gt;100&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt; i&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;++&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;)&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;{&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; arr.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;push&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;(&lt;/font&gt;&lt;/span&gt;c&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;)&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;}&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;document.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;getElementById&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="st0"&gt;&lt;font color="#3366cc"&gt;'list'&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;)&lt;/font&gt;&lt;/span&gt;.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;innerHTML&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; arr.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;join&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="st0"&gt;&lt;font color="#3366cc"&gt;''&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;)&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
      &lt;/td&gt;

      &lt;td style="border-bottom: rgb(180,180,180) 1px solid; border-left: rgb(180,180,180) 0px solid; padding-bottom: 3px; border-right-width: 0px; padding-left: 8px; padding-right: 8px; border-right-color: ; border-top: rgb(180,180,180) 0px solid; padding-top: 3px; border-image: initial" id="results-2" class="results" title="Ran 66 times in 0.054 seconds." align="center"&gt;&lt;font style="font-size: 12pt" face="Times New Roman"&gt;1,234&lt;/font&gt;&lt;small style="display: block"&gt;&lt;font face="Times New Roman"&gt;&lt;font style="font-size: 9.6pt"&gt;±0.35%&lt;/font&gt;&lt;/font&gt;&lt;/small&gt;&lt;span style="display: block"&gt;&lt;font face="Times New Roman"&gt;&lt;font style="font-size: 9.6pt"&gt;61% slower&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr style="margin-bottom: 16px"&gt;
      &lt;th style="border-bottom: rgb(180,180,180) 1px solid; min-width: 100px; border-left: rgb(180,180,180) 0px solid; padding-bottom: 3px; background-color: rgb(221,228,234); padding-left: 8px; padding-right: 8px; border-top: rgb(180,180,180) 0px solid; border-right: rgb(180,180,180) 1px solid; padding-top: 3px; background-origin: initial; background-clip: initial; border-image: initial" id="title-3" title="Click to run this test again." tabindex="tabindex" scope="row" align="center"&gt;
        &lt;div style="overflow-x: auto; overflow-y: auto; max-width: 200px; word-wrap: break-word"&gt;&lt;font face="Times New Roman"&gt;&lt;font style="font-size: 12pt"&gt;Doc Fragment&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;
      &lt;/th&gt;

      &lt;td style="border-bottom: rgb(180,180,180) 1px solid; border-left: rgb(180,180,180) 0px solid; padding-bottom: 3px; background-color: transparent; padding-left: 8px; padding-right: 8px; border-top: rgb(180,180,180) 0px solid; border-right: rgb(180,180,180) 1px solid; padding-top: 3px; border-image: initial" class="code" width="650"&gt;
        &lt;pre style="overflow-x: auto; overflow-y: auto; width: 650px; word-wrap: break-word; white-space: pre-wrap"&gt;&lt;code style="font-family: "&gt;&lt;span style="color: " class="kw2"&gt;&lt;font color="#003366"&gt;var&lt;/font&gt;&lt;/span&gt; doc &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; document.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;createDocumentFragment&lt;/font&gt;&lt;/span&gt;&lt;font color="#009900"&gt;&lt;span style="color: " class="br0"&gt;(&lt;/span&gt;&lt;span style="color: " class="br0"&gt;)&lt;/span&gt;&lt;/font&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: " class="kw2"&gt;&lt;font color="#003366"&gt;var&lt;/font&gt;&lt;/span&gt; c &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; d.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;first&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;+&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="st0"&gt;&lt;font color="#3366cc"&gt;' '&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;+&lt;/font&gt;&lt;/span&gt; d.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;second&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: " class="kw1"&gt;&lt;font color="#000066"&gt;for&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="kw2"&gt;&lt;font color="#003366"&gt;var&lt;/font&gt;&lt;/span&gt; i &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="nu0"&gt;&lt;font color="#cc0000"&gt;0&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt; i &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="nu0"&gt;&lt;font color="#cc0000"&gt;100&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt; i&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;++&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;)&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;{&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &lt;span style="color: " class="kw2"&gt;&lt;font color="#003366"&gt;var&lt;/font&gt;&lt;/span&gt; e &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; document.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;createElement&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="st0"&gt;&lt;font color="#3366cc"&gt;&amp;quot;li&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;)&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; e.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;textContent&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; c&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; doc.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;appendChild&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;(&lt;/font&gt;&lt;/span&gt;e&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;)&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;}&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;document.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;getElementById&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="st0"&gt;&lt;font color="#3366cc"&gt;'list'&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;)&lt;/font&gt;&lt;/span&gt;.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;appendChild&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;(&lt;/font&gt;&lt;/span&gt;doc&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;)&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
      &lt;/td&gt;

      &lt;td style="border-bottom: rgb(180,180,180) 1px solid; border-left: rgb(180,180,180) 0px solid; padding-bottom: 3px; border-right-width: 0px; background-color: rgb(156,238,130); padding-left: 8px; padding-right: 8px; border-right-color: ; border-top: rgb(180,180,180) 0px solid; padding-top: 3px; background-origin: initial; background-clip: initial; border-image: initial" id="results-3" class="results fastest" title="Ran 162 times in 0.054 seconds." align="center"&gt;&lt;font style="font-size: 12pt" face="Times New Roman"&gt;3,020&lt;/font&gt;&lt;small style="display: block"&gt;&lt;font face="Times New Roman"&gt;&lt;font style="font-size: 9.6pt"&gt;±3.24%&lt;/font&gt;&lt;/font&gt;&lt;/small&gt;&lt;span style="display: block"&gt;&lt;font face="Times New Roman"&gt;&lt;font style="font-size: 9.6pt"&gt;fastest&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr style="margin-bottom: 16px"&gt;
      &lt;th style="border-bottom: rgb(180,180,180) 1px solid; min-width: 100px; border-left: rgb(180,180,180) 0px solid; padding-bottom: 3px; background-color: rgb(221,228,234); padding-left: 8px; padding-right: 8px; border-top: rgb(180,180,180) 0px solid; border-right: rgb(180,180,180) 1px solid; padding-top: 3px; background-origin: initial; background-clip: initial; border-image: initial" id="title-4" title="Click to run this test again." tabindex="tabindex" scope="row" align="center"&gt;
        &lt;div style="overflow-x: auto; overflow-y: auto; max-width: 200px; word-wrap: break-word"&gt;&lt;font face="Times New Roman"&gt;&lt;font style="font-size: 12pt"&gt;Array (using index)&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;
      &lt;/th&gt;

      &lt;td style="border-bottom: rgb(180,180,180) 1px solid; border-left: rgb(180,180,180) 0px solid; padding-bottom: 3px; background-color: transparent; padding-left: 8px; padding-right: 8px; border-top: rgb(180,180,180) 0px solid; border-right: rgb(180,180,180) 1px solid; padding-top: 3px; border-image: initial" class="code" width="650"&gt;
        &lt;pre style="overflow-x: auto; overflow-y: auto; width: 650px; word-wrap: break-word; white-space: pre-wrap"&gt;&lt;code style="font-family: "&gt;&lt;span style="color: " class="kw2"&gt;&lt;font color="#003366"&gt;var&lt;/font&gt;&lt;/span&gt; arr &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; &lt;font color="#009900"&gt;&lt;span style="color: " class="br0"&gt;[&lt;/span&gt;&lt;span style="color: " class="br0"&gt;]&lt;/span&gt;&lt;/font&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: " class="kw2"&gt;&lt;font color="#003366"&gt;var&lt;/font&gt;&lt;/span&gt; c &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="st0"&gt;&lt;font color="#3366cc"&gt;'&amp;lt;li&amp;gt;'&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;+&lt;/font&gt;&lt;/span&gt; d.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;first&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;+&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="st0"&gt;&lt;font color="#3366cc"&gt;' '&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;+&lt;/font&gt;&lt;/span&gt; d.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;second&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;+&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="st0"&gt;&lt;font color="#3366cc"&gt;'&amp;lt;/li&amp;gt;'&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: " class="kw1"&gt;&lt;font color="#000066"&gt;for&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="kw2"&gt;&lt;font color="#003366"&gt;var&lt;/font&gt;&lt;/span&gt; i &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="nu0"&gt;&lt;font color="#cc0000"&gt;0&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt; i &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="nu0"&gt;&lt;font color="#cc0000"&gt;100&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt; i&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;++&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;)&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;{&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; arr&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;[&lt;/font&gt;&lt;/span&gt;i&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;]&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; c&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;}&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;document.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;getElementById&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="st0"&gt;&lt;font color="#3366cc"&gt;'list'&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;)&lt;/font&gt;&lt;/span&gt;.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;innerHTML&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; arr.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;join&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="st0"&gt;&lt;font color="#3366cc"&gt;''&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;)&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
      &lt;/td&gt;

      &lt;td style="border-bottom: rgb(180,180,180) 1px solid; border-left: rgb(180,180,180) 0px solid; padding-bottom: 3px; border-right-width: 0px; padding-left: 8px; padding-right: 8px; border-right-color: ; border-top: rgb(180,180,180) 0px solid; padding-top: 3px; border-image: initial" id="results-4" class="results" title="Ran 68 times in 0.056 seconds." align="center"&gt;&lt;font style="font-size: 12pt" face="Times New Roman"&gt;1,223&lt;/font&gt;&lt;small style="display: block"&gt;&lt;font face="Times New Roman"&gt;&lt;font style="font-size: 9.6pt"&gt;±0.46%&lt;/font&gt;&lt;/font&gt;&lt;/small&gt;&lt;span style="display: block"&gt;&lt;font face="Times New Roman"&gt;&lt;font style="font-size: 9.6pt"&gt;61% slower&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr style="margin-bottom: 16px"&gt;
      &lt;th style="border-bottom: rgb(180,180,180) 1px solid; min-width: 100px; border-left: rgb(180,180,180) 0px solid; padding-bottom: 3px; background-color: rgb(221,228,234); padding-left: 8px; padding-right: 8px; border-top: rgb(180,180,180) 0px solid; border-right: rgb(180,180,180) 1px solid; padding-top: 3px; background-origin: initial; background-clip: initial; border-image: initial" id="title-5" title="Click to run this test again." tabindex="tabindex" scope="row" align="center"&gt;
        &lt;div style="overflow-x: auto; overflow-y: auto; max-width: 200px; word-wrap: break-word"&gt;&lt;font face="Times New Roman"&gt;&lt;font style="font-size: 12pt"&gt;Array join then string concat&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;
      &lt;/th&gt;

      &lt;td style="border-bottom: rgb(180,180,180) 1px solid; border-left: rgb(180,180,180) 0px solid; padding-bottom: 3px; background-color: transparent; padding-left: 8px; padding-right: 8px; border-top: rgb(180,180,180) 0px solid; border-right: rgb(180,180,180) 1px solid; padding-top: 3px; border-image: initial" class="code" width="650"&gt;
        &lt;pre style="overflow-x: auto; overflow-y: auto; width: 650px; word-wrap: break-word; white-space: pre-wrap"&gt;&lt;code style="font-family: "&gt;&lt;span style="color: " class="kw2"&gt;&lt;font color="#003366"&gt;var&lt;/font&gt;&lt;/span&gt; arr &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; &lt;font color="#009900"&gt;&lt;span style="color: " class="br0"&gt;[&lt;/span&gt;&lt;span style="color: " class="br0"&gt;]&lt;/span&gt;&lt;/font&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: " class="kw2"&gt;&lt;font color="#003366"&gt;var&lt;/font&gt;&lt;/span&gt; c &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; d.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;first&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;+&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="st0"&gt;&lt;font color="#3366cc"&gt;' '&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;+&lt;/font&gt;&lt;/span&gt; d.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;second&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: " class="kw1"&gt;&lt;font color="#000066"&gt;for&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="kw2"&gt;&lt;font color="#003366"&gt;var&lt;/font&gt;&lt;/span&gt; i &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="nu0"&gt;&lt;font color="#cc0000"&gt;0&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt; i &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="nu0"&gt;&lt;font color="#cc0000"&gt;100&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt; i&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;++&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;)&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;{&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; arr&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;[&lt;/font&gt;&lt;/span&gt;i&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;]&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; c&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;}&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;document.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;getElementById&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="st0"&gt;&lt;font color="#3366cc"&gt;'list'&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;)&lt;/font&gt;&lt;/span&gt;.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;innerHTML&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="st0"&gt;&lt;font color="#3366cc"&gt;'&amp;lt;li&amp;gt;'&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;+&lt;/font&gt;&lt;/span&gt; arr.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;join&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="st0"&gt;&lt;font color="#3366cc"&gt;'&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;'&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;)&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;+&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="st0"&gt;&lt;font color="#3366cc"&gt;'&amp;lt;/li&amp;gt;'&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
      &lt;/td&gt;

      &lt;td style="border-bottom: rgb(180,180,180) 1px solid; border-left: rgb(180,180,180) 0px solid; padding-bottom: 3px; border-right-width: 0px; padding-left: 8px; padding-right: 8px; border-right-color: ; border-top: rgb(180,180,180) 0px solid; padding-top: 3px; border-image: initial" id="results-5" class="results" title="Ran 71 times in 0.057 seconds." align="center"&gt;&lt;font style="font-size: 12pt" face="Times New Roman"&gt;1,252&lt;/font&gt;&lt;small style="display: block"&gt;&lt;font face="Times New Roman"&gt;&lt;font style="font-size: 9.6pt"&gt;±0.37%&lt;/font&gt;&lt;/font&gt;&lt;/small&gt;&lt;span style="display: block"&gt;&lt;font face="Times New Roman"&gt;&lt;font style="font-size: 9.6pt"&gt;60% slower&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr style="margin-bottom: 16px"&gt;
      &lt;th style="border-bottom: rgb(180,180,180) 1px solid; min-width: 100px; border-left: rgb(180,180,180) 0px solid; padding-bottom: 3px; background-color: rgb(221,228,234); padding-left: 8px; padding-right: 8px; border-top: rgb(180,180,180) 0px solid; border-right: rgb(180,180,180) 1px solid; padding-top: 3px; background-origin: initial; background-clip: initial; border-image: initial" id="title-6" title="Click to run this test again." tabindex="tabindex" scope="row" align="center"&gt;
        &lt;div style="overflow-x: auto; overflow-y: auto; max-width: 200px; word-wrap: break-word"&gt;&lt;font face="Times New Roman"&gt;&lt;font style="font-size: 12pt"&gt;DOM List&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;
      &lt;/th&gt;

      &lt;td style="border-bottom: rgb(180,180,180) 1px solid; border-left: rgb(180,180,180) 0px solid; padding-bottom: 3px; background-color: transparent; padding-left: 8px; padding-right: 8px; border-top: rgb(180,180,180) 0px solid; border-right: rgb(180,180,180) 1px solid; padding-top: 3px; border-image: initial" class="code" width="650"&gt;
        &lt;pre style="overflow-x: auto; overflow-y: auto; width: 650px; word-wrap: break-word; white-space: pre-wrap"&gt;&lt;code style="font-family: "&gt;&lt;span style="color: " class="kw2"&gt;&lt;font color="#003366"&gt;var&lt;/font&gt;&lt;/span&gt; list &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; document.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;getElementById&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="st0"&gt;&lt;font color="#3366cc"&gt;'list'&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;)&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: " class="kw2"&gt;&lt;font color="#003366"&gt;var&lt;/font&gt;&lt;/span&gt; c &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; d.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;first&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;+&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="st0"&gt;&lt;font color="#3366cc"&gt;' '&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;+&lt;/font&gt;&lt;/span&gt; d.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;second&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: " class="kw1"&gt;&lt;font color="#000066"&gt;for&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="kw2"&gt;&lt;font color="#003366"&gt;var&lt;/font&gt;&lt;/span&gt; i &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="nu0"&gt;&lt;font color="#cc0000"&gt;0&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt; i &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="nu0"&gt;&lt;font color="#cc0000"&gt;100&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt; i&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;++&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;)&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;{&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &lt;span style="color: " class="kw2"&gt;&lt;font color="#003366"&gt;var&lt;/font&gt;&lt;/span&gt; e &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; document.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;createElement&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="st0"&gt;&lt;font color="#3366cc"&gt;&amp;quot;li&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;)&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; e.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;textContent&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; c&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; list.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;appendChild&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;(&lt;/font&gt;&lt;/span&gt;e&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;)&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;}&lt;/font&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
      &lt;/td&gt;

      &lt;td style="border-bottom: rgb(180,180,180) 1px solid; border-left: rgb(180,180,180) 0px solid; padding-bottom: 3px; border-right-width: 0px; background-color: rgb(156,238,130); padding-left: 8px; padding-right: 8px; border-right-color: ; border-top: rgb(180,180,180) 0px solid; padding-top: 3px; background-origin: initial; background-clip: initial; border-image: initial" id="results-6" class="results fastest" title="Ran 166 times in 0.053 seconds." align="center"&gt;&lt;font style="font-size: 12pt" face="Times New Roman"&gt;3,144&lt;/font&gt;&lt;small style="display: block"&gt;&lt;font face="Times New Roman"&gt;&lt;font style="font-size: 9.6pt"&gt;±0.00%&lt;/font&gt;&lt;/font&gt;&lt;/small&gt;&lt;span style="display: block"&gt;&lt;font face="Times New Roman"&gt;&lt;font style="font-size: 9.6pt"&gt;fastest&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr style="margin-bottom: 16px"&gt;
      &lt;th style="border-bottom: rgb(180,180,180) 1px solid; min-width: 100px; border-left: rgb(180,180,180) 0px solid; padding-bottom: 3px; background-color: rgb(221,228,234); padding-left: 8px; padding-right: 8px; border-top: rgb(180,180,180) 0px solid; border-right: rgb(180,180,180) 1px solid; padding-top: 3px; background-origin: initial; background-clip: initial; border-image: initial" id="title-7" title="Click to run this test again." tabindex="tabindex" scope="row" align="center"&gt;
        &lt;div style="overflow-x: auto; overflow-y: auto; max-width: 200px; word-wrap: break-word"&gt;&lt;font face="Times New Roman"&gt;&lt;font style="font-size: 12pt"&gt;jquery&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;
      &lt;/th&gt;

      &lt;td style="border-bottom: rgb(180,180,180) 1px solid; border-left: rgb(180,180,180) 0px solid; padding-bottom: 3px; background-color: transparent; padding-left: 8px; padding-right: 8px; border-top: rgb(180,180,180) 0px solid; border-right: rgb(180,180,180) 1px solid; padding-top: 3px; border-image: initial" class="code" width="650"&gt;
        &lt;pre style="overflow-x: auto; overflow-y: auto; width: 650px; word-wrap: break-word; white-space: pre-wrap"&gt;&lt;code style="font-family: "&gt;&lt;span style="color: " class="kw2"&gt;&lt;font color="#003366"&gt;var&lt;/font&gt;&lt;/span&gt; $list &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; $&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="st0"&gt;&lt;font color="#3366cc"&gt;&amp;quot;#list&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;)&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: " class="kw2"&gt;&lt;font color="#003366"&gt;var&lt;/font&gt;&lt;/span&gt; c &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="st0"&gt;&lt;font color="#3366cc"&gt;'&amp;lt;li&amp;gt;'&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;+&lt;/font&gt;&lt;/span&gt; d.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;first&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;+&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="st0"&gt;&lt;font color="#3366cc"&gt;' '&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;+&lt;/font&gt;&lt;/span&gt; d.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;second&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;+&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="st0"&gt;&lt;font color="#3366cc"&gt;'&amp;lt;/li&amp;gt;'&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: " class="kw1"&gt;&lt;font color="#000066"&gt;for&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="kw2"&gt;&lt;font color="#003366"&gt;var&lt;/font&gt;&lt;/span&gt; i &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="nu0"&gt;&lt;font color="#cc0000"&gt;0&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt; i &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="nu0"&gt;&lt;font color="#cc0000"&gt;100&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt; i&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;++&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;)&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;{&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; $list.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;append&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;(&lt;/font&gt;&lt;/span&gt;c&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;)&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;}&lt;/font&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
      &lt;/td&gt;

      &lt;td style="border-bottom: rgb(180,180,180) 1px solid; border-left: rgb(180,180,180) 0px solid; padding-bottom: 3px; border-right-width: 0px; background-color: rgb(255,192,203); padding-left: 8px; padding-right: 8px; border-right-color: ; border-top: rgb(180,180,180) 0px solid; padding-top: 3px; background-origin: initial; background-clip: initial; border-image: initial" id="results-7" class="results slowest" title="Ran 28 times in 0.065 seconds." align="center"&gt;&lt;font style="font-size: 12pt" face="Times New Roman"&gt;428&lt;/font&gt;&lt;small style="display: block"&gt;&lt;font face="Times New Roman"&gt;&lt;font style="font-size: 9.6pt"&gt;±9.06%&lt;/font&gt;&lt;/font&gt;&lt;/small&gt;&lt;span style="display: block"&gt;&lt;font face="Times New Roman"&gt;&lt;font style="font-size: 9.6pt"&gt;86% slower&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr style="margin-bottom: 16px"&gt;
      &lt;th style="border-bottom-color: ; min-width: 100px; border-left: rgb(180,180,180) 0px solid; padding-bottom: 3px; background-color: rgb(221,228,234); padding-left: 8px; padding-right: 8px; border-bottom-width: 0px; border-top: rgb(180,180,180) 0px solid; border-right: rgb(180,180,180) 1px solid; padding-top: 3px; background-origin: initial; background-clip: initial; border-image: initial" id="title-8" title="Click to run this test again." tabindex="tabindex" scope="row" align="center"&gt;
        &lt;div style="overflow-x: auto; overflow-y: auto; max-width: 200px; word-wrap: break-word"&gt;&lt;font face="Times New Roman"&gt;&lt;font style="font-size: 12pt"&gt;doc fragment 2&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;
      &lt;/th&gt;

      &lt;td style="border-bottom: 0px; border-left: rgb(180,180,180) 0px solid; padding-bottom: 3px; background-color: transparent; padding-left: 8px; padding-right: 8px; border-top: rgb(180,180,180) 0px solid; border-right: rgb(180,180,180) 1px solid; padding-top: 3px; border-image: initial" class="code" width="650"&gt;
        &lt;pre style="overflow-x: auto; overflow-y: auto; width: 650px; word-wrap: break-word; white-space: pre-wrap"&gt;&lt;code style="font-family: "&gt;&lt;span style="color: " class="kw2"&gt;&lt;font color="#003366"&gt;var&lt;/font&gt;&lt;/span&gt; doc &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; document.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;createDocumentFragment&lt;/font&gt;&lt;/span&gt;&lt;font color="#009900"&gt;&lt;span style="color: " class="br0"&gt;(&lt;/span&gt;&lt;span style="color: " class="br0"&gt;)&lt;/span&gt;&lt;/font&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: " class="kw2"&gt;&lt;font color="#003366"&gt;var&lt;/font&gt;&lt;/span&gt; c &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; d.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;first&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;+&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="st0"&gt;&lt;font color="#3366cc"&gt;' '&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;+&lt;/font&gt;&lt;/span&gt; d.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;second&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: " class="kw2"&gt;&lt;font color="#003366"&gt;var&lt;/font&gt;&lt;/span&gt; e &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; document.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;createElement&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="st0"&gt;&lt;font color="#3366cc"&gt;&amp;quot;li&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;)&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;e.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;textContent&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; c&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: " class="kw1"&gt;&lt;font color="#000066"&gt;for&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="kw2"&gt;&lt;font color="#003366"&gt;var&lt;/font&gt;&lt;/span&gt; i &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;=&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="nu0"&gt;&lt;font color="#cc0000"&gt;0&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt; i &lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="nu0"&gt;&lt;font color="#cc0000"&gt;100&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt; i&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;++&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;)&lt;/font&gt;&lt;/span&gt; &lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;{&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; doc.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;appendChild&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;(&lt;/font&gt;&lt;/span&gt;e.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;cloneNode&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="kw2"&gt;&lt;font color="#003366"&gt;true&lt;/font&gt;&lt;/span&gt;&lt;font color="#009900"&gt;&lt;span style="color: " class="br0"&gt;)&lt;/span&gt;&lt;span style="color: " class="br0"&gt;)&lt;/span&gt;&lt;/font&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;}&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;document.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;getElementById&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="st0"&gt;&lt;font color="#3366cc"&gt;'list'&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;)&lt;/font&gt;&lt;/span&gt;.&lt;span style="color: " class="me1"&gt;&lt;font color="#660066"&gt;appendChild&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;(&lt;/font&gt;&lt;/span&gt;doc&lt;span style="color: " class="br0"&gt;&lt;font color="#009900"&gt;)&lt;/font&gt;&lt;/span&gt;&lt;span style="color: " class="sy0"&gt;&lt;font color="#339933"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
      &lt;/td&gt;

      &lt;td style="border-bottom-color: ; border-left: rgb(180,180,180) 0px solid; padding-bottom: 3px; border-right-width: 0px; background-color: rgb(156,238,130); padding-left: 8px; padding-right: 8px; border-bottom-width: 0px; border-right-color: ; border-top: rgb(180,180,180) 0px solid; padding-top: 3px; background-origin: initial; background-clip: initial; border-image: initial" id="results-8" class="results fastest" title="Ran 174 times in 0.054 seconds." align="center"&gt;&lt;font style="font-size: 12pt" face="Times New Roman"&gt;3,241&lt;/font&gt;&lt;small style="display: block"&gt;&lt;font face="Times New Roman"&gt;&lt;font style="font-size: 9.6pt"&gt;±11.16%&lt;/font&gt;&lt;/font&gt;&lt;/small&gt;&lt;span style="display: block"&gt;&lt;font face="Times New Roman"&gt;&lt;font style="font-size: 9.6pt"&gt;fastest&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;

&lt;h2 style="padding-bottom: 0px; border-right-width: 0px; margin: 0px 0px 16px; padding-left: 0px; padding-right: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px; border-image: initial"&gt;
  &lt;br /&gt;Conclusion&lt;/h2&gt;



&lt;p&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 14px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top: 0px; border-right: 0px; padding-top: 0px" border="0" align="left" src="http://media.comicvine.com/uploads/5/54183/1320070-cliff_robertson.gif" width="122" height="92" /&gt;As Peter Parker’s Uncle said in Spider-Man, “With great power comes great responsibility”. The same can be said about the power jQuery provides to developers. Take time to research sections of code that you know are critical for the performance of your application. Just because you can use a particular function doesn’t mean you should. Check out &lt;a href="http://james.padolsey.com/jquery/"&gt;http://james.padolsey.com/jquery/&lt;/a&gt; if you’d like an easy way to see what jQuery functions are doing behind the scenes.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.pluralsight.com/"&gt;&lt;img border="0" src="http://weblogs.asp.net/blogs/dwahlin/pluralsight.png" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you’re interested in learning more about jQuery or JavaScript check out my &lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=jquery-fundamentals"&gt;jQuery Fundamentals&lt;/a&gt; or &lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=structuring-javascript"&gt;Structuring JavaScript Code&lt;/a&gt; courses from Pluralsight. We also offer onsite/online training options as well at &lt;a href="http://www.thewahlingroup.com"&gt;http://www.thewahlingroup.com&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8290248" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/JavaScript/default.aspx">JavaScript</category></item><item><title>jQuery Tip #1 – Defining a Context When Using Selectors</title><link>http://weblogs.asp.net/dwahlin/archive/2012/02/07/jquery-tip-1-defining-a-context-when-using-selectors.aspx</link><pubDate>Wed, 08 Feb 2012 07:06:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8288465</guid><dc:creator>dwahlin</dc:creator><slash:comments>9</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=8288465</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2012/02/07/jquery-tip-1-defining-a-context-when-using-selectors.aspx#comments</comments><description>&lt;p&gt;I really enjoy working with jQuery and have had the opportunity to use it a lot over the years on various projects.&amp;#160; It’s an essential part of my “technology tool belt”. My company has also started providing new &lt;a href="http://www.thewahlingroup.com" target="_blank"&gt;training&lt;/a&gt; classes on jQuery to various companies and I’ve had a lot of great questions come up about best practices, tips and tricks, when certain functions should be used over other functions, and more.&lt;/p&gt;  &lt;p&gt;I decided to put together a series of posts that highlight simple tips and tricks that I’ve used in jQuery applications over the years to provide some guidance to developers new to jQuery and provide answers to different questions I’ve been asked. In this first post I’ll cover an oldie but goodie tip – defining a context when using selectors. It’s something I struggled with when I first started using jQuery but once I found the secret (which is quite easy) it changed how I used selectors and how I used CSS classes in my HTML.    &lt;br /&gt;    &lt;br /&gt;&lt;/p&gt;  &lt;h2&gt;Defining a Context when using Selectors&lt;/h2&gt;  &lt;p&gt;Selectors are an essential part of jQuery that provide a great way to locate nodes in the DOM quickly and easily. For example, the following selector can be used to find all &lt;i&gt;div&lt;/i&gt; elements with a class of &lt;i&gt;panel&lt;/i&gt; on them in a page:     &lt;br /&gt;    &lt;br /&gt;&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;panelDivs = $(&lt;span style="color: maroon"&gt;'div.panel'&lt;/span&gt;); &lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;Selectors are well documented at &lt;a href="http://api.jquery.com/category/selectors"&gt;http://api.jquery.com/category/selectors&lt;/a&gt; so I won't rehash what they are or how to use them here. However, I do want to mention one simple yet powerful tip that many people new to jQuery will find useful. It's one of the tips that I've ended up using over and over as I build applications. To demonstrate the technique let’s walk through a simple example.&lt;/p&gt;

&lt;p&gt;Selectors can be used in the following way to find all elements with a class of &lt;i&gt;panel&lt;/i&gt; on them: 

  &lt;br /&gt;

  &lt;br /&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;panels = $(&lt;span style="color: maroon"&gt;'.panel'&lt;/span&gt;);&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;However, what if you want to grab all elements with a &lt;i&gt;panel&lt;/i&gt; class that are children of a given parent container element? To better understand the scenario, consider the following HTML: 

  &lt;br /&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;div &lt;/span&gt;&lt;span style="color: red"&gt;id&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;emailContainer&amp;quot;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;div &lt;/span&gt;&lt;span style="color: red"&gt;class&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;panel&amp;quot;&amp;gt;
        &lt;/span&gt;…&lt;br /&gt;    &lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;div&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;div &lt;/span&gt;&lt;span style="color: red"&gt;class&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;panel&amp;quot;&amp;gt;
        &lt;/span&gt;…&lt;br /&gt;    &lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;div&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;div&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;div &lt;/span&gt;&lt;span style="color: red"&gt;id&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;ordersContainer&amp;quot;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;div &lt;/span&gt;&lt;span style="color: red"&gt;class&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;panel&amp;quot;&amp;gt;
        &lt;/span&gt;…&lt;br /&gt;    &lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;div&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;div &lt;/span&gt;&lt;span style="color: red"&gt;class&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;panel&amp;quot;&amp;gt;
        &lt;/span&gt;…&lt;br /&gt;    &lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;div&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;div&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;Assume that you already have a reference to the &lt;i&gt;emailContainer&lt;/i&gt; div stored in a variable named &lt;i&gt;emailDiv&lt;/i&gt;: 

  &lt;br /&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;emailDiv = $(&lt;span style="color: maroon"&gt;'#emailContainer'&lt;/span&gt;);&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;How do you find all div elements with a &lt;i&gt;panel&lt;/i&gt; class on them within the &lt;i&gt;emailDiv&lt;/i&gt; element as opposed to finding every one within the page? One technique is to use the jQuery find() function: 

  &lt;br /&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;panels = emailDiv.find(&lt;span style="color: maroon"&gt;'div.panel'&lt;/span&gt;);&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;You can alternatively supply a context object to the selector as shown next. This is the technique I normally use mainly because it’s something I’ve used for quite awhile (and old habits are hard to break). 

  &lt;br /&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;panels = $(&lt;span style="color: maroon"&gt;'div.panel'&lt;/span&gt;, emailDiv);&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;Which way is the best? It depends on who you talk to although you can check out some live performance tests at &lt;a href="http://jsperf.com/jquery-find-vs-context-sel"&gt;http://jsperf.com/jquery-find-vs-context-sel&lt;/a&gt; that infer that find() has a slight performance advantage. Regardless, knowing how to supply a context when using selectors is a great technique to understand and useful in many different scenarios.&lt;/p&gt;

&lt;p&gt;My development team has been using this technique a lot in an application that has several panels with a consistent set of CSS classes defined on elements within each panel. We’re using a plugin that we need to dynamically re-size as the panel changes size and created a function called refreshPanel() that accepts the panel to refresh. The object passed in to the function is used as the context for several selectors (it’s a jQuery object) to identify a starting point for searching elements with specific CSS classes. Here’s a section of a JavaScript file that defines refreshPanel(). &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;...&lt;br /&gt;refreshPanel = &lt;span style="color: blue"&gt;function &lt;/span&gt;(panel) {
    &lt;span style="color: blue"&gt;var &lt;/span&gt;padding = 5;
    &lt;span style="color: #006400"&gt;//Handle height
    &lt;/span&gt;&lt;span style="color: blue"&gt;if &lt;/span&gt;(panelHeight == &lt;span style="color: blue"&gt;null&lt;/span&gt;) {
        toolbarH = $(&lt;span style="color: maroon"&gt;'.toolBar'&lt;/span&gt;, panel).height();
        tableHeadH = $(&lt;span style="color: maroon"&gt;'.clientDataTable'&lt;/span&gt;, panel).height();
        maxHeight = $(window).height();
        panelHeight = (maxHeight / panels.length) - toolbarH - (tableHeadH * 2);
    }
    &lt;span style="color: #006400"&gt;//Grab panel's current height
    &lt;/span&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;h = panel.height() - toolbarH - (tableHeadH * 2);
    &lt;span style="color: #006400"&gt;//If panel's height is greater than the original panelHeight assigned in &amp;quot;if&amp;quot; above then they're maximizing
    &lt;/span&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;newHeight = (h &amp;gt; panelHeight) ? maxHeight - toolbarH - (tableHeadH * 2) : panelHeight;

    &lt;span style="color: blue"&gt;var &lt;/span&gt;w = panel.width();
    $(&lt;span style="color: maroon"&gt;'div.dataTables_scrollBody'&lt;/span&gt;, panel).height(newHeight - padding).width(w);
    $(&lt;span style="color: maroon"&gt;'.dataTables_scrollHeadInner, table.clientDataTable'&lt;/span&gt;, panel).width(w);
}&lt;br /&gt;...&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;Notice that the panel object is used throughout as the selector context which allows the function to be re-used over and over for multiple panels. We use this technique in several places which allows us to consistently use the same CSS classes over and over within a given panel. 

  &lt;br /&gt;

  &lt;br /&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;This is the first tip in a series I’ll be writing about jQuery. Although this tip is simple (and hopefully something you already know about if you’re an experienced jQuery developer), it’s very useful in many real-world situations. 
  &lt;br /&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;div&gt;&lt;a href="http://www.pluralsight.com" target="_blank"&gt;&lt;img style="background-image: none; border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" src="http://weblogs.asp.net/blogs/dwahlin/pluralsight.png" /&gt;&lt;/a&gt;&amp;#160;&lt;/div&gt;

&lt;div style="margin-bottom: 20px"&gt;If you’re interested in learning more about jQuery or JavaScript check out my &lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=jquery-fundamentals" target="_blank"&gt;jQuery Fundamentals&lt;/a&gt; or &lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=structuring-javascript" target="_blank"&gt;Structuring JavaScript Code&lt;/a&gt; courses from Pluralsight. We also offer onsite/online training options as well at &lt;a href="http://www.thewahlingroup.com"&gt;http://www.thewahlingroup.com&lt;/a&gt;. &lt;/div&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8288465" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/JavaScript/default.aspx">JavaScript</category></item><item><title>Upcoming ASP.NET, HTML5 and Windows 8 Talks and Workshops at DevConnections 2012</title><link>http://weblogs.asp.net/dwahlin/archive/2012/02/04/upcoming-asp-net-html5-and-windows-8-talks-and-workshops-at-devconnections-2012.aspx</link><pubDate>Sun, 05 Feb 2012 00:15:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8282153</guid><dc:creator>dwahlin</dc:creator><slash:comments>2</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=8282153</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2012/02/04/upcoming-asp-net-html5-and-windows-8-talks-and-workshops-at-devconnections-2012.aspx#comments</comments><description>&lt;p&gt;It’s that time of the year again! &lt;a href="http://devconnections.com/home.aspx" target="_blank"&gt;DevConnections 2012&lt;/a&gt; is right around the corner and we have a lot of great new workshops and sessions planned for the ASP.NET and Client-Dev (HTML5, Windows 8 Metro, JavaScript, jQuery, etc.) tracks. &lt;/p&gt;  &lt;p&gt;The keynote at DevConnections will be given by the one and only &lt;a href="https://twitter.com/#!/scottgu" target="_blank"&gt;Scott Guthrie&lt;/a&gt; who’s always up to something cool and is a lot of fun to listen to.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devconnections.com/shows/sp2012/registration.aspx?s=183"&gt;&lt;img title="image" border="0" alt="image" src="http://johnpapa.net/Media/Default/Windows-Live-Writer/Spring-2012-DevConnections_C09C/image_19.png" width="504" height="107" /&gt;&lt;/a&gt;    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;Several other great speakers will be at the conference as well. Here’s a quick sampling:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="https://twitter.com/#!/John_Papa" target="_blank"&gt;John Papa&lt;/a&gt; (awesome presenter and a close personal friend of mine) &lt;/li&gt;    &lt;li&gt;&lt;a href="https://twitter.com/#!/shanselman"&gt;Scott Hanselman&lt;/a&gt; (everyone’s favorite speaker/comedian)&lt;/li&gt;    &lt;li&gt;&lt;a href="https://twitter.com/#!/swalther"&gt;Stephen Walther&lt;/a&gt;&amp;#160; (one of the smartest people I’ve met and a great guy)&lt;/li&gt;    &lt;li&gt;&lt;a href="https://twitter.com/#!/richcampbell"&gt;Richard Campbell&lt;/a&gt; (super fun guy who’s a blast to listen/talk to on &lt;a href="http://dotnetrocks.com/" target="_blank"&gt;.NET Rocks&lt;/a&gt;)&lt;/li&gt;    &lt;li&gt;&lt;a href="https://twitter.com/#!/mkristensen"&gt;Mads Kristensen&lt;/a&gt; (of Visual Studio plugin fame)&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://devconnections.com/shows/sp2012/registration.aspx?s=183"&gt;&lt;img title="image" border="0" alt="image" src="http://johnpapa.net/Media/Default/Windows-Live-Writer/Spring-2012-DevConnections_C09C/image_16.png" width="504" height="106" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;And of course there are many more! Sessions are only part of a conference experience. Yeah there are the parties too … but the real value is in the hallway conversations and the people you meet and continue to talk to beyond the conference event. DevConnections is a great place to strike up these conversations as its one of the largest gatherings of super experts in our industry … and they are all very approachable. There will also be a panel discussions with many of us, which is a great chance to put us on the spot.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;…&lt;/strong&gt;Thanks to John for letting me hijack that last paragraph along with the pictures he put on his &lt;a href="http://johnpapa.net/" target="_blank"&gt;blog&lt;/a&gt;. I thought he nailed what DevConnections is all about in just a few sentences.&lt;/p&gt;  &lt;p&gt;I’ll be co-presenting a full day jQuery workshop with John on Monday, March 26th. We really enjoy co-presenting and have a lot of great jQuery topics to discuss. You do have to register for the workshops so make sure to do that when you register for the conference.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devconnections.com/shows/sp2012/registration.aspx?s=183"&gt;&lt;img title="image" border="0" alt="image" src="http://johnpapa.net/Media/Default/Windows-Live-Writer/Spring-2012-DevConnections_C09C/image_12.png" width="504" height="107" /&gt;&lt;/a&gt;&lt;/p&gt;    &lt;p&gt;&lt;strong&gt;&lt;font size="3"&gt;Workshop&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;APR02: Building Ajax-Enabled Applications with jQuery (9:00AM - 4:00PM) &lt;/b&gt;    &lt;br /&gt;&lt;b&gt;Add'l Fee $399.00&lt;/b&gt;    &lt;br /&gt;John Papa &amp;amp; Dan Wahlin    &lt;br /&gt;    &lt;br /&gt;Building cross-browser AJAX applications can be a fun yet challenging proposition. In this workshop, you’ll learn how to put the joy back into AJAX development using the jQuery script library. Learn how jQuery selectors can reduce code and simplify the process of finding DOM elements, how chaining can be used to accomplish multiple tasks with a single line of code and how cross-browser AJAX calls can be made using built-in jQuery functionality. Other topics covered include using client-side templates as well as built-in plugins. If you’ve wanted to learn jQuery but haven’t made the time, this is the workshop for you since we’ll take you from the ground floor all the way to the top.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font size="3"&gt;Sessions&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;I’m also presenting or co-presenting 4 other sessions. If you’ll be at the conference please stop by and introduce yourself.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devconnections.com/shows/sp2012/registration.aspx?s=183"&gt;&lt;img title="image" border="0" alt="image" src="http://johnpapa.net/Media/Default/Windows-Live-Writer/Spring-2012-DevConnections_C09C/image_11.png" width="504" height="109" /&gt;&lt;/a&gt;    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;CWI202: Fundamentals of Windows 8 HTML/JavaScript Metro Style Apps&lt;/b&gt;    &lt;br /&gt;Dan Wahlin    &lt;br /&gt;    &lt;br /&gt;Heard the buzz about Windows 8 Metro style applications but don’t know where to start? In this session, you’ll learn how your existing HTML, JavaScript, and CSS skills can be used to build Windows 8 Metro applications. Learn about different Visual Studio 11 project templates, built-in scripts, and Windows Runtime (WinRT) calls that you can make to build robust applications that will be capable of targeting millions of Windows users on the desktop and on tablets in the near future.    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;CHT201: Developing an HTML5/jQuery Application - End to End&lt;/b&gt;    &lt;br /&gt;Dan Wahlin    &lt;br /&gt;    &lt;br /&gt;HTML5 is all the rage these days but where do you look to find robust examples of using it along with jQuery, jQuery templates, Ajax calls, data access technologies, and more? In this session, Dan Wahlin will walk through an application called Account at a Glance that demonstrates how key HTML5 technologies can be integrated and used to present data to users in different ways. Topics covered include exposing data to the client using Entity Framework Code First and RESTful services, using jQuery templates to render data, JavaScript techniques for structuring code, the role of HTML5 semantic tags, as well as how technologies such as the canvas, SVG, and video can be used. If you want to learn HTML5 techniques and strategies from a real app, then this session is for you.    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;CJS301: Techniques, Strategies, and Patterns for Structuring JavaScript Code &lt;/b&gt;    &lt;br /&gt;John Papa &amp;amp; Dan Wahlin    &lt;br /&gt;    &lt;br /&gt;Are you writing a lot of JavaScript code and trying to apply good practices to make it more maintainable and flexible? In this session, learn about common practices to make avoid problems such as polluting the global namespace and code that executes inconsistently, by using patterns such as separation and the Revealing Module Pattern. You will leave this session with several tips on how to write clean, more maintainable, and consistent code.     &lt;br /&gt;    &lt;br /&gt;&lt;strong&gt;&amp;lt;shamelessPlug&amp;gt;     &lt;br /&gt;      &lt;br /&gt;&lt;/strong&gt;If you can’t make the conference make sure to check out my new Structuring JavaScript Code course at &lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=structuring-javascript" target="_blank"&gt;Pluralsight.com&lt;/a&gt;. If you’re still writing “function spaghetti code” I’ll show you several techniques/patterns that will really improve the re-use and maintainability of your code.Good stuff to know if you’re building Web applications.    &lt;br /&gt;    &lt;br /&gt;&lt;strong&gt;&amp;lt;/shamelessPlug&amp;gt;&lt;/strong&gt;    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;CJS202: Templating and Data Binding for HTML5 Applications with JsRender and JsViews &lt;/b&gt;    &lt;br /&gt;John Papa &amp;amp; Dan Wahlin    &lt;br /&gt;    &lt;br /&gt;Interested in using the latest JavaScript libraries for templating and data binding your HTML5 app? In this session you will learn how to simplify JavaScript development using JsRender and JsViews (the replacements for jQuery templates). Learn how JsRender brings a new templating library to HTML5 development that has a code-less tag syntax, high performance, no dependency on jQuery nor a DOM, supports creating custom functions, and uses pure string-based rendering. You will also see how JsViews compliments JsRender by providing data binding features through observability of changes that work with plain old JavaScript objects (POJO).&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8282153" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/ASP.NET+AJAX/default.aspx">ASP.NET AJAX</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/JSON/default.aspx">JSON</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/ASP.NET+MVC/default.aspx">ASP.NET MVC</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/HTML5/default.aspx">HTML5</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/XAML/default.aspx">XAML</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/DevConnections/default.aspx">DevConnections</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/CSS/default.aspx">CSS</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Design+Patterns/default.aspx">Design Patterns</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/WinRT/default.aspx">WinRT</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Windows+8/default.aspx">Windows 8</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/EF+Code+First/default.aspx">EF Code First</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Metro+Apps/default.aspx">Metro Apps</category></item><item><title>Working with the JavaScript “this” Keyword</title><link>http://weblogs.asp.net/dwahlin/archive/2011/12/28/working-with-the-javascript-this-keyword.aspx</link><pubDate>Wed, 28 Dec 2011 16:49:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8186790</guid><dc:creator>dwahlin</dc:creator><slash:comments>13</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=8186790</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2011/12/28/working-with-the-javascript-this-keyword.aspx#comments</comments><description>&lt;p&gt;JavaScript's &amp;quot;this&amp;quot; keyword can be a bit tricky to work with depending on the context in which it's used. When it's used with patterns such as the &lt;a href="http://weblogs.asp.net/dwahlin/archive/2011/08/01/techniques-strategies-and-patterns-for-structuring-javascript-code-the-prototype-pattern.aspx" target="_blank"&gt;Prototype&lt;/a&gt; or &lt;a href="http://weblogs.asp.net/dwahlin/archive/2011/08/03/techniques-strategies-and-patterns-for-structuring-javascript-code-revealing-prototype-pattern.aspx" target="_blank"&gt;Revealing Prototype&lt;/a&gt; patterns working with &amp;quot;this&amp;quot; can be challenging in some cases. Unlike languages such as C# or Java, &amp;quot;this&amp;quot; can change context. For example, if a Calculator object named calc calls an add() function then &amp;quot;this&amp;quot; represents the Calculator object which means you can easily access any variables defined in the object such as a variable named &lt;i&gt;tax&lt;/i&gt; by simply using &lt;i&gt;this.tax&lt;/i&gt;. &lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;    &lt;pre class="code"&gt;calc.add(2, 2); &lt;span style="color: #006400"&gt;//Using &amp;quot;this&amp;quot; inside of the add() function gets you to the calc object&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;
  &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;However, if add() makes a call to another function then &amp;quot;this&amp;quot; changes context and no longer represents the Calculator object. In fact, &amp;quot;this&amp;quot; will change to the &lt;i&gt;window&lt;/i&gt; object which means you can no longer access variables defined in the Calculator object such as &lt;i&gt;tax&lt;/i&gt;. That presents a bit of a problem that’s especially challenging if you’ve never dealt with it before.&lt;/p&gt;

&lt;p&gt;There are several ways to handle this challenge. First, you can pass &amp;quot;this&amp;quot; as a parameter to other functions. An example of passing &amp;quot;this&amp;quot; between functions is shown next. If a Calculator object calls a clearNumbers() function then you can easily access the Calculator object's constructor variables within the function. However, once clearNumbers() calls other functions such as setVal() or setEquation(), &amp;quot;this&amp;quot; changes context. To account for the change, the code passes &amp;quot;this&amp;quot; as a parameter to each of the functions and they then use it like normal. Although this type of code works, it pollutes your function parameters in some cases and becomes a little messy to work with (at least in my opinion).&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;Calculator = &lt;span style="color: blue"&gt;function &lt;/span&gt;(eq) {
    &lt;span style="color: #006400"&gt;//state goes here
    &lt;/span&gt;&lt;span style="color: blue"&gt;this&lt;/span&gt;.eqCtl = document.getElementById(eq);
    &lt;span style="color: blue"&gt;this&lt;/span&gt;.lastNumber;
    &lt;span style="color: blue"&gt;this&lt;/span&gt;.equalsPressed;
    &lt;span style="color: blue"&gt;this&lt;/span&gt;.operatorSet;&lt;br /&gt;&lt;span style="color: blue"&gt;    this&lt;/span&gt;.tax; 
};

Calculator.prototype = &lt;span style="color: blue"&gt;function &lt;/span&gt;() {
    &lt;span style="color: #006400"&gt;//private members
    &lt;/span&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;add = &lt;span style="color: blue"&gt;function &lt;/span&gt;(x, y) {
        &lt;span style="color: blue"&gt;this&lt;/span&gt;.eqCtl.innerHTML = x + y + &lt;span style="color: blue"&gt;this&lt;/span&gt;.tax;
    },

    subtract = &lt;span style="color: blue"&gt;function &lt;/span&gt;(x, y) {
        &lt;span style="color: blue"&gt;this&lt;/span&gt;.eqCtl.innerHTML = x – y + &lt;span style="color: blue"&gt;this&lt;/span&gt;.tax;
    },

    setVal = &lt;span style="color: blue"&gt;function &lt;/span&gt;(val, &lt;strong&gt;thisObj&lt;/strong&gt;) {
        &lt;strong&gt;thisObj&lt;/strong&gt;.currNumberCtl.innerHTML = val;
    },

    setEquation = &lt;span style="color: blue"&gt;function &lt;/span&gt;(val, &lt;strong&gt;thisObj&lt;/strong&gt;) {
        &lt;strong&gt;thisObj&lt;/strong&gt;.eqCtl.innerHTML = val;
    },

    &lt;span style="color: #006400"&gt;//Other functions omitted for brevity&lt;br /&gt;
    &lt;/span&gt;clearNumbers = &lt;span style="color: blue"&gt;function &lt;/span&gt;() {
        &lt;span style="color: blue"&gt;this&lt;/span&gt;.lastNumber = &lt;span style="color: blue"&gt;null&lt;/span&gt;;
        &lt;span style="color: blue"&gt;this&lt;/span&gt;.equalsPressed = &lt;span style="color: blue"&gt;this&lt;/span&gt;.operatorSet = &lt;span style="color: blue"&gt;false&lt;/span&gt;;&lt;br /&gt; &lt;br /&gt;        &lt;span style="color: #006400"&gt;//Pass the Calculator object that called clearNumbers() &lt;br /&gt;        //to other functions as a parameter&lt;/span&gt; 
      &lt;strong&gt;  setVal(&lt;span style="color: maroon"&gt;'0'&lt;/span&gt;, &lt;span style="color: blue"&gt;this&lt;/span&gt;);
        setEquation(&lt;span style="color: maroon"&gt;''&lt;/span&gt;, &lt;span style="color: blue"&gt;this&lt;/span&gt;);&lt;/strong&gt;
    };

    &lt;span style="color: #006400"&gt;//public members
    &lt;/span&gt;&lt;span style="color: blue"&gt;return &lt;/span&gt;{
        add: add,
        subtract: subtract,
        clearNumbers: clearNumbers
    };
} ();&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;Another technique that can be used involves JavaScript's call() function. This function can be used to invoke functions and set the context of &amp;quot;this&amp;quot; while the call is being made. For example, if you want to call a function named setVal() and preserve the current value of &amp;quot;this&amp;quot; as the call is made then you can do the following:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;setVal.call(&lt;span style="color: blue"&gt;this&lt;/span&gt;, &lt;span style="color: maroon"&gt;'yourParameterValue'&lt;/span&gt;);&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;The current value of &amp;quot;this&amp;quot; will be passed along automatically to the setVal() function and it can safely use this.tax in the case of a Calculator object.&lt;/p&gt;

&lt;p&gt;The following code uses the call() function to update the code shown earlier. The clearNumbers() function uses JavaScript's call() function to invoke the setVal() and setEquation() functions and preserve the current value of &amp;quot;this&amp;quot; in the process. Notice that the setVal() and setEquation() functions no longer need the extra parameter as the functions shown earlier did and can simply use &amp;quot;this&amp;quot; to access Calculator object variables defined in the object's constructor. This simplifies the call by eliminating the need for the extra parameter and makes the code a lot cleaner. 
  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;Calculator = &lt;span style="color: blue"&gt;function &lt;/span&gt;(eq) {
    &lt;span style="color: #006400"&gt;//state goes here
    &lt;/span&gt;&lt;span style="color: blue"&gt;this&lt;/span&gt;.eqCtl = document.getElementById(eq);
    &lt;span style="color: blue"&gt;this&lt;/span&gt;.lastNumber;
    &lt;span style="color: blue"&gt;this&lt;/span&gt;.equalsPressed;
    &lt;span style="color: blue"&gt;this&lt;/span&gt;.operatorSet;&lt;br /&gt;&lt;span style="color: blue"&gt;    this&lt;/span&gt;.tax;
};

Calculator.prototype = &lt;span style="color: blue"&gt;function &lt;/span&gt;() {
    &lt;span style="color: #006400"&gt;//private members
    &lt;/span&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;add = &lt;span style="color: blue"&gt;function &lt;/span&gt;(x, y) {
        &lt;span style="color: blue"&gt;this&lt;/span&gt;.eqCtl.innerHTML = x + y + &lt;span style="color: blue"&gt;this&lt;/span&gt;.tax;
    },

    subtract = &lt;span style="color: blue"&gt;function &lt;/span&gt;(x, y) {
        &lt;span style="color: blue"&gt;this&lt;/span&gt;.eqCtl.innerHTML = x – y + &lt;span style="color: blue"&gt;this&lt;/span&gt;.tax;
    },

    setVal = &lt;span style="color: blue"&gt;function &lt;/span&gt;(val) {
        &lt;span style="color: blue"&gt;&lt;strong&gt;this&lt;/strong&gt;&lt;/span&gt;.currNumberCtl.innerHTML = val;
    },

    setEquation = &lt;span style="color: blue"&gt;function &lt;/span&gt;(val) {
        &lt;span style="color: blue"&gt;&lt;strong&gt;this&lt;/strong&gt;&lt;/span&gt;.eqCtl.innerHTML = val;
    },

    &lt;span style="color: #006400"&gt;//Other functions omitted for brevity

    &lt;/span&gt;clearNumbers = &lt;span style="color: blue"&gt;function &lt;/span&gt;() {
        &lt;span style="color: blue"&gt;this&lt;/span&gt;.lastNumber = &lt;span style="color: blue"&gt;null&lt;/span&gt;;
        &lt;span style="color: blue"&gt;this&lt;/span&gt;.equalsPressed = &lt;span style="color: blue"&gt;this&lt;/span&gt;.operatorSet = &lt;span style="color: blue"&gt;false&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #006400"&gt;        &lt;br /&gt;        //Set context of &amp;quot;this&amp;quot; to the Calculator object that called clearNumbers()&lt;/span&gt;
&lt;strong&gt;        setVal.call(&lt;span style="color: blue"&gt;this&lt;/span&gt;, &lt;span style="color: maroon"&gt;'0'&lt;/span&gt;);
        setEquation.call(&lt;span style="color: blue"&gt;this&lt;/span&gt;, &lt;span style="color: maroon"&gt;''&lt;/span&gt;);&lt;/strong&gt;
    };

    &lt;span style="color: #006400"&gt;//public members
    &lt;/span&gt;&lt;span style="color: blue"&gt;return &lt;/span&gt;{
        add: add,
        subtract: subtract,
        clearNumbers: clearNumbers
    };
} ();&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;Another example of where “this” gets tricky is inside of jQuery event handlers. For example, assume that an init() function is called that adds a click event to DOM elements. What if you want to get to a value of “this” representing the container Calculator object while inside of the click event handler function? The context of “this” changes to the anchor tag making it challenging. Two potential options that can be used are shown next.&lt;/p&gt;

&lt;p&gt;The first option is to store the value of “this” as a variable outside of the click event handler function. By doing this a closure is created and you can still access the original value of “this” when the event fires:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;Calculator.prototype = {
    &lt;span style="color: #006400"&gt;//private members
    &lt;/span&gt;init: &lt;span style="color: blue"&gt;function&lt;/span&gt;() {
        &lt;span style="color: #006400"&gt;//Option 1 for working with &amp;quot;this&amp;quot;
        &lt;/span&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;calcObject = &lt;span style="color: blue"&gt;this&lt;/span&gt;;
        $(&lt;span style="color: maroon"&gt;'a'&lt;/span&gt;).click(&lt;span style="color: blue"&gt;function &lt;/span&gt;() {
            &lt;span style="color: #006400"&gt;//Can't simply use this or $(this) 
            //since &amp;quot;this&amp;quot; represents the anchor now
            //calcObject will represent the Calculator object
            &lt;/span&gt;calcObject.highlight($(&lt;span style="color: blue"&gt;this&lt;/span&gt;));
        });
    },

    highlight: &lt;span style="color: blue"&gt;function&lt;/span&gt;(anchor) {
        anchor.toggleClass(&lt;span style="color: maroon"&gt;'highlight'&lt;/span&gt;);
    }
};&lt;br /&gt;&lt;/pre&gt;

&lt;br /&gt;

&lt;br /&gt;Another option is to use an overloaded version of various jQuery event handlers such as on() to pass “this” and make it accessible through the event object: 

&lt;br /&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;Calculator.prototype = {
    &lt;span style="color: #006400"&gt;//private members
    &lt;/span&gt;init: &lt;span style="color: blue"&gt;function&lt;/span&gt;() {
        &lt;span style="color: #006400"&gt;//Option 2 for working with &amp;quot;this&amp;quot;
        //Pass &amp;quot;this&amp;quot; into the on() call
        &lt;/span&gt;$(&lt;span style="color: maroon"&gt;'a'&lt;/span&gt;).on(&lt;span style="color: maroon"&gt;'click'&lt;/span&gt;, { calcObject: &lt;span style="color: blue"&gt;this &lt;/span&gt;}, &lt;span style="color: blue"&gt;function &lt;/span&gt;(event) {
            &lt;span style="color: #006400"&gt;//Access the original value of &amp;quot;this&amp;quot; 
            //through the event object's data property
            &lt;/span&gt;event.data.calcObject.highlight($(&lt;span style="color: blue"&gt;this&lt;/span&gt;));
        });
    },

    highlight: &lt;span style="color: blue"&gt;function&lt;/span&gt;(anchor) {
        anchor.toggleClass(&lt;span style="color: maroon"&gt;'highlight'&lt;/span&gt;);
    }
};&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;Notice that “this” is assigned to an object literal property named calcObject in the on() parameters. Once the click event fires the event object passed to the callback function can be used to get to the data property which exposes the calcObject value that was passed in.&lt;/p&gt;

&lt;p&gt;Although working with JavaScript’s “this” keyword can be challenging in some scenarios, there are several different techniques that can be used to make it easier to work with. Have any other techniques you like to use? Feel free to leave a comment and share your technique with everyone.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h4&gt;Videos on JavaScript and jQuery&lt;/h4&gt;

&lt;br /&gt;If you're interested in additional information about structuring JavaScript code check out my &lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=structuring-javascript" target="_blank"&gt;Structuring JavaScript Code&lt;/a&gt; course created for &lt;a href="http://www.pluralsight.com" target="_blank"&gt;PluralSight&lt;/a&gt;. Here's a sample from the course covering closures. 

&lt;br /&gt;

&lt;br /&gt;&lt;strong&gt;Demo - Working with Closures in JavaScript&lt;/strong&gt; 

&lt;br /&gt;

&lt;br /&gt;&lt;object style="height:400px; width:512px" width="512" height="400"&gt;    &lt;param name="movie" value="http://www.youtube.com/v/t1B5TJQAKjM?version=3&amp;amp;feature=player_profilepage&amp;amp;hd=1"&gt;    &lt;param name="allowFullScreen" value="true"&gt;    &lt;param name="allowScriptAccess" value="always"&gt;    &lt;embed src="http://www.youtube.com/v/t1B5TJQAKjM?version=3&amp;amp;feature=player_profilepage&amp;amp;hd=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="512" height="400"&gt; &lt;/object&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;A sample video from the &lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=jquery-fundamentals" target="_blank"&gt;jQuery programming&lt;/a&gt; course that covers using the each() function is shown next:&lt;/p&gt;

&lt;br /&gt;&lt;strong&gt;Demo – Using jQuery’s each() Function&lt;/strong&gt;

&lt;br /&gt;

&lt;br /&gt;&lt;object style="height:400px; width:512px" width="512" height="400"&gt;    &lt;param name="movie" value="http://www.youtube.com/v/Fekw8FwJcOk?version=3&amp;amp;feature=player_profilepage&amp;amp;hd=1"&gt;    &lt;param name="allowFullScreen" value="true"&gt;    &lt;param name="allowScriptAccess" value="always"&gt;    &lt;embed src="http://www.youtube.com/v/Fekw8FwJcOk?version=3&amp;amp;feature=player_profilepage&amp;amp;hd=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="512" height="400"&gt; &lt;/object&gt;
&lt;br /&gt;
&lt;br /&gt;


&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8186790" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/HTML5/default.aspx">HTML5</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Design+Patterns/default.aspx">Design Patterns</category></item><item><title>Using the JavaScript Prototype Property to Structure and Extend Code</title><link>http://weblogs.asp.net/dwahlin/archive/2011/12/19/using-the-javascript-prototype-property-to-structure-and-extend-code.aspx</link><pubDate>Mon, 19 Dec 2011 19:26:46 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8144012</guid><dc:creator>dwahlin</dc:creator><slash:comments>11</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=8144012</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2011/12/19/using-the-javascript-prototype-property-to-structure-and-extend-code.aspx#comments</comments><description>&lt;p&gt;There are several different patterns that can be used in JavaScript to structure code and make it more re-useable, more maintainable, and less subject to naming collisions. Patterns like the Revealing Module Pattern, Prototype Pattern, Revealing Prototype Pattern, and others can be used to structure code and avoid what I call “function spaghetti code”. One of my favorite features offered by both the &lt;a href="http://weblogs.asp.net/dwahlin/archive/2011/08/01/techniques-strategies-and-patterns-for-structuring-javascript-code-the-prototype-pattern.aspx" target="_blank"&gt;Prototype&lt;/a&gt; and the &lt;a href="http://weblogs.asp.net/dwahlin/archive/2011/08/03/techniques-strategies-and-patterns-for-structuring-javascript-code-revealing-prototype-pattern.aspx" target="_blank"&gt;Revealing Prototype&lt;/a&gt; patterns is the extensibility they provide. They’re quite flexible especially compared to the Module or &lt;a href="http://weblogs.asp.net/dwahlin/archive/2011/08/02/techniques-strategies-and-patterns-for-structuring-javascript-code-revealing-module-pattern.aspx" target="_blank"&gt;Revealing Module&lt;/a&gt; patterns out there.&lt;/p&gt;  &lt;p&gt;Because both patterns rely on JavaScript prototyping, functions are shared across objects instances in memory and its straightforward for users of objects following these patterns to extend or override existing functionality. If you didn’t get a chance to read my previous posts on the two prototype patterns here are some basic examples of the patterns in action:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Prototype Pattern Example&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;Calculator = &lt;span style="color: blue"&gt;function &lt;/span&gt;(eq) {
    &lt;span style="color: #006400"&gt;//state goes here     
    &lt;/span&gt;&lt;span style="color: blue"&gt;this&lt;/span&gt;.eqCtl = document.getElementById(eq);
};

Calculator.prototype = { 
    add: &lt;span style="color: blue"&gt;function &lt;/span&gt;(x, y) {
        &lt;span style="color: blue"&gt;this&lt;/span&gt;.eqCtl.innerHTML = x + y;
    },
    subtract: &lt;span style="color: blue"&gt;function &lt;/span&gt;(x, y) {
        &lt;span style="color: blue"&gt;this&lt;/span&gt;.eqCtl.innerHTML = x - y;
    } 
};&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;
    &lt;br /&gt;Revealing Prototype Pattern Example&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;Calculator = &lt;span style="color: blue"&gt;function &lt;/span&gt;(eq) {
    &lt;span style="color: #006400"&gt;//state goes here
    &lt;/span&gt;&lt;span style="color: blue"&gt;this&lt;/span&gt;.eqCtl = document.getElementById(eq);
};

Calculator.prototype = &lt;span style="color: blue"&gt;function &lt;/span&gt;() {
    &lt;span style="color: #006400"&gt;//private members
    &lt;/span&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;add = &lt;span style="color: blue"&gt;function &lt;/span&gt;(x, y) {
        &lt;span style="color: blue"&gt;this&lt;/span&gt;.eqCtl.innerHTML = x + y;
    },
    subtract = &lt;span style="color: blue"&gt;function &lt;/span&gt;(x, y) {
        &lt;span style="color: blue"&gt;this&lt;/span&gt;.eqCtl.innerHTML = x - y; 
    };

    &lt;span style="color: #006400"&gt;//public members
    &lt;/span&gt;&lt;span style="color: blue"&gt;return &lt;/span&gt;{
        add: add,
        subtract: subtract
    };
} ();&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Looking through the two examples you can see that both patterns rely on the prototype functionality available in JavaScript. The Revealing Prototype Pattern has the added functionality of being able to define public and private members within the Calculator. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sidebar:&lt;/strong&gt; Some people love the public/private feature and some people think all JavaScript code should be accessible to callers (which I’ll admit can simplify debugging in some scenarios). It really depends on your background and what you want. I personally like having the Revealing Prototype Pattern’s public/private member functionality available (mainly because of my background in Java and C#) since if you’re working with editors that support Intellisense or code help you only see the functions or variables that you should call as you’re typing. It’s all personal preference though and if you’d prefer to add an underscore in front of a variable or function to mark it as private then I say go for it – to each their own.&lt;/p&gt;

&lt;p&gt;What if you want to extend one of the Calculator objects shown above or override existing functions? When using the Prototype or Revealing Prototype patterns this is possible since they both rely on prototyping. If you’re new to prototyping here’s a quick introduction to using the prototype property and different ways it can be used in your JavaScript code. 
  &lt;br /&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;h1&gt;Getting Started with JavaScript Prototyping 
  &lt;br /&gt;&lt;/h1&gt;

&lt;p&gt;Prototyping allows objects to inherit, override, and extend functionality provided by other objects in a similar manner as inheritance, overriding, abstraction, and related technologies do in C#, Java, and other languages. Every object you create in JavaScript has a prototype property by default that can be accessed. To better understand prototyping, take a look at the example below. Rather than adding methods directly into the BaseCalculator constructor definition as with patterns like the Revealing Module Pattern, this example relies on separate prototype definitions to define two functions.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;BaseCalculator = &lt;span style="color: blue"&gt;function &lt;/span&gt;() {&lt;br /&gt;&lt;span style="color: #006400"&gt;    //Define a variable unique to each instance of BaseCalculator&lt;br /&gt;&lt;/span&gt;    &lt;span style="color: blue"&gt;this&lt;/span&gt;.decimalDigits = 2;
};
        
&lt;span style="color: #006400"&gt;//Extend BaseCalculator using prototype
&lt;/span&gt;BaseCalculator.prototype.add = &lt;span style="color: blue"&gt;function &lt;/span&gt;(x, y) {
    &lt;span style="color: blue"&gt;return &lt;/span&gt;x + y;
};&lt;br /&gt;
BaseCalculator.prototype.subtract = &lt;span style="color: blue"&gt;function &lt;/span&gt;(x, y) {
    &lt;span style="color: blue"&gt;return &lt;/span&gt;x - y;
};&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;This code defines a BaseCalculator object with a variable named &lt;em&gt;decimalDigits&lt;/em&gt; in the constructor. The code then extends the BaseCalculator object using the prototype property. Two functions are added including add(x,y) and subtract(x,y). This type of definition can be simplified as shown above with the Prototype Pattern by using an object literal to define the prototype functions:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;font color="#000000"&gt;Base&lt;/font&gt;&lt;/span&gt;Calculator = &lt;span style="color: blue"&gt;function&lt;/span&gt;() {
    &lt;span style="color: #006400"&gt;//state goes here
    &lt;/span&gt;&lt;span style="color: blue"&gt;this&lt;/span&gt;.decimalDigits = 2;
};

BaseCalculator.prototype = {
    &lt;span style="color: #006400"&gt;//private members
    &lt;/span&gt;add: &lt;span style="color: blue"&gt;function&lt;/span&gt;(x, y) {
        &lt;span style="color: blue"&gt;return&lt;/span&gt; x + y;
    },
    subtract: &lt;span style="color: blue"&gt;function&lt;/span&gt;(x, y) {
        &lt;span style="color: blue"&gt;return&lt;/span&gt; x - y;
    }
};&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;Once BaseCalculator is defined you can inherit from it by doing the following:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;Calculator = &lt;span style="color: blue"&gt;function &lt;/span&gt;() {&lt;br /&gt;    &lt;font color="#006400"&gt;//Define a variable unique to each instance of Calculator
&lt;/font&gt;    &lt;span style="color: blue"&gt;this&lt;/span&gt;.tax = 5;
};
        
Calculator.prototype = &lt;span style="color: blue"&gt;new &lt;/span&gt;BaseCalculator();&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Note that Calculator is defined with a constructor that includes a &lt;em&gt;tax&lt;/em&gt; variable that’s unique to each object instance. The Calculator’s prototype points to a new instance of BaseCalculator() allowing Calculator to inherit the add() and subtract() functions automatically. These functions are shared between both types and not duplicated in memory as instances are created which is a nice feature provided by the prototype property. An example of creating a new Calculator object instance is shown next:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;calc = &lt;span style="color: blue"&gt;new &lt;/span&gt;Calculator();
alert(calc.add(1, 1));&lt;br /&gt;&lt;span style="color: #006400"&gt;//variable defined in the BaseCalculator parent object is accessible from the derived Calculator object’s constructor&lt;/span&gt;
alert(calc.decimalDigits); &lt;span style="color: #006400"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;In the previous code, BaseCalculator’s decimalDigits variable is accessible to Calculator since a new instance of BaseCalculator was supplied to the Calculator’s prototype. If you want to disable access to parent type variables defined in the constructor you can assign BaseCalculator’s prototype to Calculator’s prototype as shown next as opposed to assigning a new BaseCalculator instance:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;Calculator = &lt;span style="color: blue"&gt;function &lt;/span&gt;() {
    &lt;span style="color: blue"&gt;this&lt;/span&gt;.tax= &lt;span style="color: blue"&gt;5&lt;/span&gt;;
};

Calculator.prototype = BaseCalculator.prototype;&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;Because the BaseCalcuator’s prototype is assigned directly to Calculator’s prototype the &lt;em&gt;decimalDigits&lt;/em&gt; variable defined in BaseCalculator will no longer be accessible if you go through a Calculator object instance. The &lt;em&gt;tax&lt;/em&gt; variable defined in Calculator would be accessible of course. For example, the following code will throw a JavaScript error when the code tries to access &lt;em&gt;decimalDigits&lt;/em&gt;. This is due to BaseCalculator’s constructor no longer being assigned to the Calculator prototype.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;calc = &lt;span style="color: blue"&gt;new &lt;/span&gt;Calculator();
alert(calc.add(1, 1));
alert(calc.decimalDigits);&lt;br /&gt;&lt;/pre&gt;

&lt;h1&gt;
  &lt;br /&gt;Overriding with Prototype 

  &lt;br /&gt;

  &lt;br /&gt;&lt;/h1&gt;

&lt;p&gt;If you’re using either the Prototype Pattern or Revealing Prototype Pattern to structure code in JavaScript (or any other object that relies on prototyping) you can take advantage of the prototype property to override existing functionality provided by a type. This can be useful in scenarios where a library built by a 3rd party is being used and you want to extend or override existing functionality without having to modify the library’s source code. Or, you may write code that you want other developers on your team to be able to enhance/override. An example of overriding the add() function provided in Calculator is shown next: 
  &lt;br /&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: #006400"&gt;//Override Calculator’s add() function &lt;/span&gt;&lt;br /&gt;Calculator.prototype.add = &lt;span style="color: blue"&gt;function &lt;/span&gt;(x, y) {
    &lt;span style="color: blue"&gt;return &lt;/span&gt;x + y + &lt;span style="color: blue"&gt;this&lt;/span&gt;.tax;
};&lt;br /&gt;
&lt;span style="color: blue"&gt;var &lt;/span&gt;calc = &lt;span style="color: blue"&gt;new &lt;/span&gt;Calculator();
alert(calc.add(1, 1));&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;This code overrides the add() function provided by BaseCalculator and modifies it to add x, y, and an instance variable named myData together. The override applies to all Calculator object instances created after the override.&lt;/p&gt;

&lt;p&gt;There’s of course more that you can do with JavaScript prototyping so I recommend reading through &lt;a href="http://dmitrysoshnikov.com/ecmascript/chapter-7-2-oop-ecmascript-implementation/#prototype" target="_blank"&gt;this post&lt;/a&gt; for additional details and more advanced examples of using the prototype property.&lt;/p&gt;

&lt;br /&gt;

&lt;h2&gt;Interested in learning more about structuring JavaScript code? &lt;/h2&gt;

&lt;h2&gt;&amp;#160;&lt;/h2&gt;
If you're interested in additional information about structuring JavaScript code check out my latest &lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=structuring-javascript"&gt;Pluralsight course&lt;/a&gt;. Here's a sample from the course covering closures and how they can be created and used. 

&lt;br /&gt;

&lt;br /&gt;&lt;strong&gt;Working with Closures in JavaScript&lt;/strong&gt; 

&lt;p&gt;
  &lt;br /&gt;&lt;object style="height:400px; width:512px"&gt;    &lt;param name="movie" value="http://www.youtube.com/v/t1B5TJQAKjM?version=3&amp;amp;feature=player_profilepage&amp;amp;hd=1"&gt;    &lt;param name="allowFullScreen" value="true"&gt;    &lt;param name="allowScriptAccess" value="always"&gt;    &lt;embed src="http://www.youtube.com/v/t1B5TJQAKjM?version=3&amp;amp;feature=player_profilepage&amp;amp;hd=1" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="512" height="400"&gt; &lt;/object&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8144012" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/HTML5/default.aspx">HTML5</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Design+Patterns/default.aspx">Design Patterns</category></item><item><title>New Pluralsight Course - Structuring JavaScript Code in HTML5 Applications</title><link>http://weblogs.asp.net/dwahlin/archive/2011/12/12/new-pluralsight-course-structuring-javascript-code-in-html5-applications.aspx</link><pubDate>Tue, 13 Dec 2011 04:26:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8114981</guid><dc:creator>dwahlin</dc:creator><slash:comments>5</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=8114981</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2011/12/12/new-pluralsight-course-structuring-javascript-code-in-html5-applications.aspx#comments</comments><description>&lt;p&gt;&lt;img src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_680A6918.png" /&gt;&lt;/p&gt;  &lt;p&gt;I just released a new course for &lt;a href="http://www.pluralsight.com" target="_blank"&gt;Pluralsight&lt;/a&gt; titled &lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=structuring-javascript" target="_blank"&gt;Structuring JavaScript Code in HTML5 Applications&lt;/a&gt; that covers different techniques, strategies, and patterns that can be used when working with JavaScript to encapsulate code, provide better re-use, simplify maintenance, and take variables and functions out of the global scope. The overall goal of the course is to show developers how to convert what I call “Function Spaghetti Code” into more encapsulated and modular code. The concepts covered are important especially since many of the HTML5 APIs (canvas, geolocation, web storage, and more) rely heavily on JavaScript. What if you’re not writing HTML5 applications yet? All of the topics are still directly applicable to any JavaScript code you may be writing.&lt;/p&gt;  &lt;p&gt;A lot of the content in the course came from lessons learned while building large and small applications for clients and samples and demos for conference talks. I’ve also had several discussions about different ways to structure JavaScript code with friends such as &lt;a href="http://johnpapa.net" target="_blank"&gt;John Papa&lt;/a&gt;, &lt;a href="http://elegantcode.com/about/jarod-ferguson/" target="_blank"&gt;Jarod Ferguson&lt;/a&gt;, and &lt;a href="http://blogs.interfacett.com/author/spike-xavier" target="_blank"&gt;Spike Xavier&lt;/a&gt; that have influenced my overall views on working with JavaScript.&amp;#160; A sample video from the course is available below that covers information about how closures can be used to create containers in code. Closures are a critical component of all of the patterns discussed in the course.&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&lt;strong&gt;Demo - Working with Closures in JavaScript&lt;/strong&gt;&lt;/p&gt;  &lt;br /&gt;&lt;object style="height:400px; width:512px"&gt;    &lt;param name="movie" value="http://www.youtube.com/v/t1B5TJQAKjM?version=3&amp;amp;feature=player_profilepage&amp;amp;hd=1"&gt;    &lt;param name="allowFullScreen" value="true"&gt;    &lt;param name="allowScriptAccess" value="always"&gt;    &lt;embed src="http://www.youtube.com/v/t1B5TJQAKjM?version=3&amp;amp;feature=player_profilepage&amp;amp;hd=1" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="512" height="400"&gt; &lt;/object&gt;  &lt;p&gt;   &lt;br /&gt;The topics covered in the &lt;em&gt;Structuring JavaScript Code in HTML5 Applications&lt;/em&gt; course are shown next:    &lt;br /&gt;&lt;/p&gt;  &lt;div class="main"&gt;   &lt;div style="clear: both"&gt;&lt;/div&gt;   &lt;script src="http://s.pluralsight.com/mn/js/cs/toc-expander-v2.js" type="text/javascript"&gt;&lt;/script&gt;    &lt;table class="linkContainer" width="450"&gt;&lt;thead&gt;&lt;/thead&gt;&lt;tbody&gt;       &lt;tr style="cursor: pointer" class="module" onclick="toggleModule();"&gt;         &lt;td style="padding-left: 0px" class="title tocModule"&gt;           &lt;div class="playButton"&gt;&lt;span style="margin-left: 10px"&gt;&lt;strong&gt;Why do we Need JavaScript Patterns?&lt;/strong&gt;&lt;/span&gt; &lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr class="tocClips"&gt;         &lt;td style="padding-left: 55px" class="clipTitle"&gt;           &lt;div&gt;Introduction&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr class="tocClips"&gt;         &lt;td style="padding-left: 55px" class="clipTitle"&gt;           &lt;div&gt;Function Spaghetti Code&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr class="tocClips"&gt;         &lt;td style="padding-left: 55px" class="clipTitle"&gt;           &lt;div&gt;Function Spaghetti Code Demo&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr class="tocClips"&gt;         &lt;td style="padding-left: 55px" class="clipTitle"&gt;           &lt;div&gt;Closures to the Rescue&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr class="tocClips"&gt;         &lt;td style="padding-left: 55px" class="clipTitle"&gt;           &lt;div&gt;Closures Demo&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr class="tocClips"&gt;         &lt;td style="padding-left: 55px" class="clipTitle"&gt;           &lt;div&gt;Closures Demo 2&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr class="tocClips"&gt;         &lt;td style="padding-left: 55px" class="clipTitle"&gt;           &lt;div&gt;Defining Variables&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr class="tocClips"&gt;         &lt;td style="padding-left: 55px" class="clipTitle"&gt;           &lt;div&gt;Defining Variables Demo&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr class="tocClips"&gt;         &lt;td style="padding-left: 55px" class="clipTitle"&gt;           &lt;div&gt;Summary&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr style="cursor: pointer" class="module" onclick="toggleModule();"&gt;         &lt;td style="padding-left: 0px" class="title tocModule"&gt;           &lt;div class="playButton"&gt;&lt;span style="margin-left: 10px"&gt;&lt;strong&gt;Prototype Pattern&lt;/strong&gt;&lt;/span&gt; &lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr class="tocClips"&gt;         &lt;td style="padding-left: 55px" class="clipTitle"&gt;           &lt;div&gt;Introduction&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr class="tocClips"&gt;         &lt;td style="padding-left: 55px" class="clipTitle"&gt;           &lt;div&gt;Prototype Pattern Pros and Cons&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr class="tocClips"&gt;         &lt;td style="padding-left: 55px" class="clipTitle"&gt;           &lt;div&gt;Prototype Pattern Structure&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr class="tocClips"&gt;         &lt;td style="padding-left: 55px" class="clipTitle"&gt;           &lt;div&gt;Using the Prototype Pattern&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr class="tocClips"&gt;         &lt;td style="padding-left: 55px" class="clipTitle"&gt;           &lt;div&gt;Prototype Pattern Extension Demo&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr class="tocClips"&gt;         &lt;td style="padding-left: 55px" class="clipTitle"&gt;           &lt;div&gt;Summary&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr style="cursor: pointer" class="module" onclick="toggleModule();"&gt;         &lt;td style="padding-left: 0px" class="title tocModule"&gt;           &lt;div class="playButton"&gt;&lt;span style="margin-left: 10px"&gt;&lt;strong&gt;Module Pattern&lt;/strong&gt;&lt;/span&gt; &lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr class="tocClips"&gt;         &lt;td style="padding-left: 55px" class="clipTitle"&gt;           &lt;div&gt;Introduction&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr class="tocClips"&gt;         &lt;td style="padding-left: 55px" class="clipTitle"&gt;           &lt;div&gt;Module Pattern Pros and Cons&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr class="tocClips"&gt;         &lt;td style="padding-left: 55px" class="clipTitle"&gt;           &lt;div&gt;Module Pattern Structure&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr class="tocClips"&gt;         &lt;td style="padding-left: 55px" class="clipTitle"&gt;           &lt;div&gt;Using the Module Pattern&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr class="tocClips"&gt;         &lt;td style="padding-left: 55px" class="clipTitle"&gt;           &lt;div&gt;Summary&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr style="cursor: pointer" class="module" onclick="toggleModule();"&gt;         &lt;td style="padding-left: 0px" class="title tocModule"&gt;           &lt;div class="playButton"&gt;&lt;span style="margin-left: 10px"&gt;&lt;strong&gt;Revealing Module Pattern&lt;/strong&gt;&lt;/span&gt; &lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr class="tocClips"&gt;         &lt;td style="padding-left: 55px" class="clipTitle"&gt;           &lt;div&gt;Introduction&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr class="tocClips"&gt;         &lt;td style="padding-left: 55px" class="clipTitle"&gt;           &lt;div&gt;Revealing Module Pros and Cons&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr class="tocClips"&gt;         &lt;td style="padding-left: 55px" class="clipTitle"&gt;           &lt;div&gt;Revealing Module Structure&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr class="tocClips"&gt;         &lt;td style="padding-left: 55px" class="clipTitle"&gt;           &lt;div&gt;Using the Revealing Module Pattern&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr class="tocClips"&gt;         &lt;td style="padding-left: 55px" class="clipTitle"&gt;           &lt;div&gt;Summary&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr style="cursor: pointer" class="module" onclick="toggleModule();"&gt;         &lt;td style="padding-left: 0px" class="title tocModule"&gt;           &lt;div class="playButton"&gt;&lt;span style="margin-left: 10px"&gt;&lt;strong&gt;Revealing Prototype Pattern&lt;/strong&gt;&lt;/span&gt; &lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr class="tocClips"&gt;         &lt;td style="padding-left: 55px" class="clipTitle"&gt;           &lt;div&gt;Introduction&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr class="tocClips"&gt;         &lt;td style="padding-left: 55px" class="clipTitle"&gt;           &lt;div&gt;Revealing Prototype Pros and Cons&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr class="tocClips"&gt;         &lt;td style="padding-left: 55px" class="clipTitle"&gt;           &lt;div&gt;Revealing Prototype Structure&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr class="tocClips"&gt;         &lt;td style="padding-left: 55px" class="clipTitle"&gt;           &lt;div&gt;Using the Revealing Prototype Pattern&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr class="tocClips"&gt;         &lt;td style="padding-left: 55px" class="clipTitle"&gt;           &lt;div&gt;Using the Revealing Prototype Pattern with 'this'&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr class="tocClips"&gt;         &lt;td style="padding-left: 55px" class="clipTitle"&gt;           &lt;div&gt;Extending the Revealing Prototype Pattern&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr class="tocClips"&gt;         &lt;td style="padding-left: 55px" class="clipTitle"&gt;           &lt;div&gt;Converting Code to the Revealing Prototype Pattern&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr class="tocClips"&gt;         &lt;td style="padding-left: 55px" class="clipTitle"&gt;           &lt;div&gt;Summary&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;     &lt;/tbody&gt;&lt;/table&gt; &lt;/div&gt;  &lt;div class="main"&gt;&amp;#160;&lt;/div&gt;  &lt;div class="main"&gt;&amp;#160;&lt;/div&gt;  &lt;div class="main"&gt;Additional courses that I’ve published for Pluralsight are shown below:&lt;/div&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=win8-intro" target="_blank"&gt;Introduction to Building Windows 8 Metro Applications&lt;/a&gt; (co-authored with John Papa)&lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.pluralsight-training.net/microsoft/courses/TableOfContents?courseName=aspdotnet-webforms4-intro"&gt;Introduction to ASP.NET 4 WebForms&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.pluralsight-training.net/microsoft/courses/TableOfContents?courseName=jquery-fundamentals"&gt;jQuery Fundamentals&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.pluralsight-training.net/microsoft/courses/TableOfContents?courseName=sharepoint-features-and-solutions-by-example"&gt;SharePoint 2007 Features and Solutions by Example&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8114981" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/HTML5/default.aspx">HTML5</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/JavaScript/default.aspx">JavaScript</category></item><item><title>Silverlight 5 Released with a lot of Great New Features</title><link>http://weblogs.asp.net/dwahlin/archive/2011/12/09/silverlight-5-released-with-a-lot-of-great-new-features.aspx</link><pubDate>Fri, 09 Dec 2011 21:03:45 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8105076</guid><dc:creator>dwahlin</dc:creator><slash:comments>3</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=8105076</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2011/12/09/silverlight-5-released-with-a-lot-of-great-new-features.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/Silverlight5_5535CF99.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Silverlight5" border="0" alt="Silverlight5" src="http://weblogs.asp.net/blogs/dwahlin/Silverlight5_thumb_0AEB14F4.png" width="240" height="79" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;Silverlight 5 was released today and there are a ton of great new features available in this release. You can download the Silverlight 5 tools for Visual Studio 2010 SP1 &lt;a href="http://ow.ly/7UBCh" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;One of the coolest new features is the built-in support Silverlight 5 now has for 3D. I’m doing a lot with 3D right now for a project (using &lt;a href="http://unity3d.com/" target="_blank"&gt;Unity 3D&lt;/a&gt;) so this is a really exciting to me. Here’s an example of Silverlight 5 3D in action from the &lt;a href="http://code.msdn.microsoft.com/silverlight/Babylon-3D-engine-f0404ace" target="_blank"&gt;Babylon 3D engine page&lt;/a&gt;:&lt;/p&gt;  &lt;p&gt;&lt;img src="http://i3.code.msdn.microsoft.com/babylon-3d-engine-f0404ace/image/file/21300/1/1832.image_thumb_7a01c4c3.png" /&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;There’s also built-in support for new media features such as trick play which allows video to be played at different speeds with automatic pitch correction for audio, hardware decoding of H.264 media, text enhancements, new controls like the PivotViewer, and much more.&lt;/p&gt;  &lt;p&gt;Over the years my consulting company has used Silverlight in Line of Business (LOB) scenarios quite extensively so I’m really excited about some of the new LOB features that Silverlight 5 provides. I recently wrote about several of the features so if you’re interested in more details check out the posts below:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://weblogs.asp.net/dwahlin/archive/2011/10/06/new-line-of-business-features-in-silverlight-5-implicit-data-templates.aspx"&gt;Implicit Data Templates&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/dwahlin/archive/2011/10/07/new-line-of-business-features-in-silverlight-5-ancestor-relativesource-binding.aspx"&gt;Ancestor RelativeSource Binding&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/dwahlin/archive/2011/10/15/new-line-of-business-features-in-silverlight-5-debugging-bindings-in-xaml.aspx"&gt;Debugging Bindings in XAML&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/dwahlin/archive/2011/10/23/new-line-of-business-features-in-silverlight-5-using-pinvoke.aspx" target="_blank"&gt;Using pInvoke&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Pete Brown provides a nice list of new features provided in Silverlight 5 that you can &lt;a href="http://10rem.net/blog/2011/12/09/announcing-the-release-of-silverlight-5" target="_blank"&gt;check out here&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8105076" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/XAML/default.aspx">XAML</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/3D/default.aspx">3D</category></item><item><title>Reducing JavaScript Code Using jsRender Templates in HTML5 Applications</title><link>http://weblogs.asp.net/dwahlin/archive/2011/11/23/reducing-javascript-code-by-using-jsrender-templates-in-html5-applications.aspx</link><pubDate>Wed, 23 Nov 2011 19:11:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8071151</guid><dc:creator>dwahlin</dc:creator><slash:comments>15</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=8071151</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2011/11/23/reducing-javascript-code-by-using-jsrender-templates-in-html5-applications.aspx#comments</comments><description>&lt;div class="post"&gt;   &lt;p class="postsub"&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_0A2B384C.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" align="right" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_5A8D19BF.png" width="237" height="69" /&gt;&lt;/a&gt;Back in November of 2010 I wrote a post titled &lt;a href="http://weblogs.asp.net/dwahlin/archive/2010/11/20/reducing-code-by-using-jquery-templates.aspx" target="_blank"&gt;Reducing Code using jQuery Templates&lt;/a&gt; that demonstrated how jQuery Templates could be used to reduce significant amounts of JavaScript code. Although the topics and code discussed in that post are still valid and relevant in today’s applications, things have a changed some when it comes to the future of jQuery Templates. I’ve had questions come up in the jQuery classes that we offer, at conferences, and online about the future of jQuery Templates so I thought I’d put a post together that provides updated information.&lt;/p&gt;    &lt;p class="postsub"&gt;To get the full story you can read &lt;a href="http://www.borismoore.com/2011/10/jquery-templates-and-jsviews-roadmap.html" target="_blank"&gt;Boris Moore’s blog&lt;/a&gt;, but in a nutshell the jQuery UI team decided to go a different direction with client-side templates and use an alternate syntax. As a result, a new script has been released called jsRender that will ultimately replace jQuery Templates - at least that’s the current plan. I’ll review a few things mentioned in my initial post here for those that aren’t familiar with templates and then show examples of using the new jsRender functionality in an application.&lt;/p&gt;    &lt;p class="postsub"&gt;Nearly every language out there uses templates in some manner to minimize the amount of code that has to be written. By using templates you can define a template structure once and use it to generate code, HTML or other formats. If you’ve created ASP.NET applications then you’re aware of how powerful and productive templates are when it comes to generating HTML output. However, what if you want to use templates on the client-side to generate HTML rather than writing a lot of JavaScript to manipulate the DOM?&lt;/p&gt;    &lt;p class="postsub"&gt;Although templates have been available in jQuery for quite awhile through various plug-ins, the jsRender template framework provides a new solution that doesn’t use CSS in strange ways or require a lot of knowledge about a template language. By using it you can define HTML templates in web pages and use them to render HTML output dynamically at runtime. You can download the jsRender script along with samples from &lt;a href="https://github.com/BorisMoore/jsrender"&gt;https://github.com/BorisMoore/jsrender&lt;/a&gt;.      &lt;br /&gt;&lt;/p&gt;    &lt;h2 class="postsub"&gt;Defining a Template Block&lt;/h2&gt;    &lt;p class="postsub"&gt;You can use client-side templates by referencing the jsRender script mentioned above and then defining a &amp;lt;script&amp;gt; block in your page with a &lt;strong&gt;type&lt;/strong&gt; of &lt;strong&gt;text/x-jquery-tmpl &lt;/strong&gt;as shown next:&lt;/p&gt;    &lt;p class="postsub"&gt;&amp;#160;&lt;/p&gt;    &lt;div class="postsub"&gt;     &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;script &lt;/span&gt;&lt;span style="color: red"&gt;id&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;OrderSummaryTemplate&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;text/x-jquery-tmpl&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;/span&gt;&amp;lt;!-- Template goes here –&amp;gt;&lt;br /&gt;
&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;script&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/pre&gt;
  &lt;/div&gt;

  &lt;p class="postsub"&gt;&amp;#160;&lt;/p&gt;

  &lt;p class="postsub"&gt;Once the script tag is defined you can place template code inside of it. Any HTML you add into the template is output automatically once the template is rendered. Of course, adding static HTML doesn’t accomplish much so jsRender provides several tags that can be placed inside of a template to define data that should be output, perform conditional logic, iterate through items, render nested templates, plus more. The key template tags available with jsRender are shown next: 
    &lt;br /&gt;

    &lt;br /&gt;&lt;/p&gt;
  &lt;style type="text/css"&gt;





   #templatetable { border: 1px solid #666666;width:100%;border-collapse: collapse;}
 
   #templatetable td { border: 1px solid #666666;}&lt;/style&gt;

  &lt;div class="postsub"&gt;
    &lt;table id="TemplateTable"&gt;&lt;tbody&gt;
        &lt;tr style="background-color: #efefef"&gt;
          &lt;td height="30" valign="top" width="20%"&gt;&lt;strong&gt;Template Tag &lt;/strong&gt;&lt;/td&gt;

          &lt;td valign="top" width="30%"&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/td&gt;

          &lt;td valign="top" width="50%"&gt;&lt;strong&gt;Description&lt;/strong&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;td valign="top"&gt;&lt;strong&gt;{{=fieldNameOrExpression}}&lt;/strong&gt;&lt;/td&gt;

          &lt;td valign="top"&gt;&lt;pre&gt;{{=DeliveryFee}}&lt;/pre&gt;&lt;/td&gt;

          &lt;td valign="top"&gt;Used to define data values that should be rendered in the template. Evaluates the specified property on the current data item and encodes the value.
            &lt;br /&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;td valign="top"&gt;&lt;strong&gt;{{=fieldNameOrExpression!}}&lt;/strong&gt;&lt;/td&gt;

          &lt;td valign="top"&gt;&lt;pre&gt;{{=Comments!}}&lt;/pre&gt;&lt;/td&gt;

          &lt;td valign="top"&gt;Used to define HTML markup strings that should be rendered by the template (notice that a ! character is placed at the end of the string). Evaluates the specified field on the current data item and doesn’t encode the value.
            &lt;br /&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;td valign="top"&gt;&lt;strong&gt;{{#if condition}}&lt;/strong&gt;&lt;/td&gt;

          &lt;td valign="top"&gt;
            &lt;pre&gt;{{#if DeliveryFee &amp;gt; 0}}&lt;br /&gt;   {{=DeliveryFee}} added to your order.&lt;br /&gt;{{/if}}&lt;/pre&gt;
          &lt;/td&gt;

          &lt;td valign="top"&gt;Used for conditional insertion of content. 
            &lt;br /&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;td valign="top"&gt;&lt;strong&gt;{{else}}&lt;/strong&gt;&lt;/td&gt;

          &lt;td valign="top"&gt;
            &lt;pre&gt;{{#if MainItems.length===0}}&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;tr&amp;gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;td&amp;gt;No items selected&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/tr&amp;gt;&lt;br /&gt;{{else}}&lt;br /&gt;    &amp;lt;tr&amp;gt;&lt;br /&gt;        &amp;lt;td&amp;gt;Ordered items!&amp;lt;/td&amp;gt;&lt;br /&gt;    &amp;lt;/tr&amp;gt;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;{{/if}}&lt;/pre&gt;
          &lt;/td&gt;

          &lt;td valign="top"&gt;Used to add additional conditional logic into jsRender templates. &lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;td valign="top"&gt;&lt;strong&gt;{{#each}}&lt;/strong&gt;&lt;/td&gt;

          &lt;td valign="top"&gt;
            &lt;pre&gt;{{#each MainItems}}&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;tr&amp;gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;td&amp;gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {{=mi.NumberOrdered}} ordered &lt;br /&gt;            at ${{=mi.Price}} per item&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/td&amp;gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/tr&amp;gt;&lt;br /&gt;{{/each}}&lt;/pre&gt;
          &lt;/td&gt;

          &lt;td valign="top"&gt;Used to iterate over a data array and render the content for each data item.&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;td valign="top"&gt;&lt;strong&gt;{{#each tmpl=”#NestedTemplateID”}}&lt;/strong&gt;&lt;/td&gt;

          &lt;td valign="top"&gt;
            &lt;pre&gt;&amp;lt;script id=&amp;quot;movieTemplate&amp;quot; type=&amp;quot;text/x-jquery-tmpl&amp;quot;&amp;gt; 
    {{#each Movies tmpl=&amp;quot;#titleTemplate&amp;quot;}}
&amp;lt;/script&amp;gt;

&amp;lt;script id=&amp;quot;titleTemplate&amp;quot; type=&amp;quot;text/x-jquery-tmpl&amp;quot;&amp;gt; 
    &amp;lt;tr class=&amp;quot;title&amp;quot;&amp;gt;&lt;br /&gt;        &amp;lt;td&amp;gt;{{=Name}}&amp;lt;/td&amp;gt;&lt;br /&gt;    &amp;lt;/tr&amp;gt;
&amp;lt;/script&amp;gt;&lt;/pre&gt;
          &lt;/td&gt;

          &lt;td valign="top"&gt;Used for composition of templates. Renders one or more nested template items within the rendered output of the parent template.&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/tbody&gt;&lt;/table&gt;
  &lt;/div&gt;

  &lt;p class="postsub"&gt;&amp;#160;&lt;/p&gt;

  &lt;h2 class="postsub"&gt;Rendering a Template&lt;/h2&gt;

  &lt;p class="postsub"&gt;Once a template is defined using a &amp;lt;script&amp;gt; block you can use jsRender’s render() function to convert data into HTML based upon the template. This is done by identifying the target element that will host the content, calling its html() function (when using jQuery). and then passing the HTML that’s generated by calling the render() function. The render() function accepts the data that the template will use to generate HTML content. An example of putting all of this together is shown next. You’ll see that the OrderSummaryOutput element is located in the DOM using a jQuery selector and that its html() function is passed the output generated by a jsRender template.&lt;/p&gt;

  &lt;p class="postsub"&gt;&amp;#160;&lt;/p&gt;

  &lt;div class="postsub"&gt;
    &lt;pre class="code"&gt;$(&lt;span style="color: maroon"&gt;&amp;quot;#OrderSummaryOutput&amp;quot;&lt;/span&gt;).html($(&lt;span style="color: maroon"&gt;&amp;quot;#OrderSummaryTemplate&amp;quot;&lt;/span&gt;).render(data));&lt;br /&gt;&lt;/pre&gt;
  &lt;/div&gt;
  

  &lt;p class="postsub"&gt;&amp;#160;&lt;/p&gt;

  &lt;p class="postsub"&gt;The data can be created locally from an object literal or retrieved from a remote service call as JSON as shown nextt:&lt;/p&gt;

  &lt;p class="postsub"&gt;&amp;#160;&lt;/p&gt;

  &lt;div class="postsub"&gt;
    &lt;pre class="code"&gt;$.ajax({
    dataType: &lt;span style="color: maroon"&gt;'jsonp&lt;span style="color: maroon"&gt;'&lt;/span&gt;&lt;/span&gt;,
    url: moviesServiceUrl,
    jsonp: &lt;span style="color: maroon"&gt;'&lt;/span&gt;&lt;span style="color: maroon"&gt;$callback&lt;span style="color: maroon"&gt;'&lt;/span&gt;&lt;/span&gt;,
    success: showMovies
});

&lt;span style="color: #006400"&gt;// Within the callback, use .tmpl() to render the data.
&lt;/span&gt;&lt;span style="color: blue"&gt;function &lt;/span&gt;showMovies(data)
{
    &lt;span style="color: #006400"&gt;// Render the template with the &amp;quot;movies&amp;quot; data and insert
    // the rendered HTML under the 'movieList' element
    &lt;/span&gt;$(&lt;span style="color: maroon"&gt;&amp;quot;#movieList&amp;quot;&lt;/span&gt;).html($(&lt;span style="color: maroon"&gt;&amp;quot;#moviesTemplate&amp;quot;&lt;/span&gt;).render(data));&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;
  &lt;/div&gt;

  &lt;h2 class="postsub"&gt;&amp;#160;&lt;/h2&gt;

  &lt;h2 class="postsub"&gt;jsRender in Action&lt;/h2&gt;

  &lt;p class="postsub"&gt;A sample application that I created to demonstrate jsRender in action can be &lt;a href="http://dl.dropbox.com/u/6037348/HTML5AndJavaScript/OrderUpJSRender.zip"&gt;downloaded here&lt;/a&gt; (it’s part of the sample code available with our &lt;strong&gt;jQuery Web Programming&lt;/strong&gt; training course). The sample app is an ASP.NET MVC 3 project named “Order Up” that leverages jQuery heavily and uses jsRender to display order details. An example of the output that’s rendered is shown next: 

    &lt;br /&gt;&lt;/p&gt;

  &lt;p class="postsub"&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_5FCC389E.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_39F6123B.png" width="661" height="653" /&gt;&lt;/a&gt;&lt;/p&gt;

  &lt;p class="postsub"&gt;
    &lt;br /&gt;The template used to generated the Totals, Delivery Information, Items Ordered and Accessories Ordered sections is shown next:&lt;/p&gt;

  &lt;p class="postsub"&gt;&amp;#160;&lt;/p&gt;

  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;script &lt;/span&gt;&lt;span style="color: red"&gt;id&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;OrderSummaryTemplate&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;text/x-jquery-tmpl&amp;quot;&amp;gt;
    &lt;/span&gt;&amp;lt;table style=&amp;quot;width:100%;&amp;quot;&amp;gt;
        &amp;lt;tbody&amp;gt;             
            &amp;lt;tr&amp;gt;
                &amp;lt;td class=&amp;quot;OrderHeader&amp;quot;&amp;gt;Totals:&amp;lt;/td&amp;gt;                    
            &amp;lt;/tr&amp;gt;                    
            &amp;lt;tr&amp;gt;
                &amp;lt;td style=&amp;quot;font-size:12pt;&amp;quot;&amp;gt;
                    &amp;lt;table style=&amp;quot;width:400px;&amp;quot;&amp;gt;
                        &amp;lt;tr&amp;gt;
                            &amp;lt;td style=&amp;quot;width:50%;&amp;quot;&amp;gt;Sub Total:&amp;lt;/td&amp;gt;
                            &amp;lt;td&amp;gt;$&amp;lt;span id=&amp;quot;FinalSubTotal&amp;quot;&amp;gt;{{=FinalSubTotal}}&amp;lt;/span&amp;gt;&amp;lt;/td&amp;gt;
                        &amp;lt;/tr&amp;gt;
                        &amp;lt;tr&amp;gt;
                            &amp;lt;td style=&amp;quot;width:50%;&amp;quot;&amp;gt;Sales Tax:&amp;lt;/td&amp;gt;
                            &amp;lt;td&amp;gt;$&amp;lt;span id=&amp;quot;FinalSalesTax&amp;quot;&amp;gt;{{=FinalSalesTax }}&amp;lt;/span&amp;gt;&amp;lt;/td&amp;gt;
                        &amp;lt;/tr&amp;gt;
                        {{#if DeliveryFee &amp;gt; 0}}
                            &amp;lt;tr&amp;gt;
                                &amp;lt;td style=&amp;quot;width:50%;&amp;quot;&amp;gt;Delivery Fee:&amp;lt;/td&amp;gt;
                                &amp;lt;td&amp;gt;$&amp;lt;span id=&amp;quot;FinalDeliveryFee&amp;quot;&amp;gt;{{=DeliveryFee }}&amp;lt;/span&amp;gt;&amp;lt;/td&amp;gt;
                            &amp;lt;/tr&amp;gt;
                        {{/if}}
                        &amp;lt;tr&amp;gt;
                            &amp;lt;td style=&amp;quot;width:50%;&amp;quot;&amp;gt;Admin Fee:&amp;lt;/td&amp;gt;
                            &amp;lt;td&amp;gt;$&amp;lt;span id=&amp;quot;FinalAdminFee&amp;quot;&amp;gt;{{=AdminFee }}&amp;lt;/span&amp;gt;&amp;lt;/td&amp;gt;
                        &amp;lt;/tr&amp;gt;
                        &amp;lt;tr style=&amp;quot;border-top:1px solid black;&amp;quot;&amp;gt;
                            &amp;lt;td style=&amp;quot;width:50%;font-weight:bold;&amp;quot;&amp;gt;Total:&amp;lt;/td&amp;gt;
                            &amp;lt;td&amp;gt;$&amp;lt;span id=&amp;quot;FinalTotal&amp;quot;&amp;gt;{{=FinalTotal }}&amp;lt;/span&amp;gt;&amp;lt;/td&amp;gt;
                        &amp;lt;/tr&amp;gt;   
                        &amp;lt;tr&amp;gt;
                            &amp;lt;td colspan=&amp;quot;2&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/td&amp;gt;
                        &amp;lt;/tr&amp;gt;
                        &amp;lt;tr&amp;gt;
                            &amp;lt;td colspan=&amp;quot;2&amp;quot;&amp;gt;Will be charged to your credit card ending with {{=CreditCard }}&amp;lt;/td&amp;gt;
                        &amp;lt;/tr&amp;gt;                     
                    &amp;lt;/table&amp;gt;                        
                &amp;lt;/td&amp;gt;
            &amp;lt;/tr&amp;gt; 
            &amp;lt;tr&amp;gt;
                &amp;lt;td&amp;gt;&amp;amp;nbsp;&amp;lt;/td&amp;gt;
            &amp;lt;/tr&amp;gt; 
            &amp;lt;tr&amp;gt;
                &amp;lt;td class=&amp;quot;OrderHeader&amp;quot;&amp;gt;Delivery Information&amp;lt;/td&amp;gt;                    
            &amp;lt;/tr&amp;gt;
            &amp;lt;tr&amp;gt;
                &amp;lt;td&amp;gt;
                    &amp;lt;table style=&amp;quot;width:500px;&amp;quot;&amp;gt;
                        &amp;lt;tr&amp;gt;
                            &amp;lt;td style=&amp;quot;width:25%;&amp;quot;&amp;gt;Deliver To:&amp;lt;/td&amp;gt;
                            &amp;lt;td&amp;gt;{{=DeliveryName}}&amp;lt;/td&amp;gt;
                        &amp;lt;/tr&amp;gt;
                        &amp;lt;tr&amp;gt;
                            &amp;lt;td style=&amp;quot;width:25%;&amp;quot;&amp;gt;Address:&amp;lt;/td&amp;gt;
                            &amp;lt;td&amp;gt;{{=DeliveryAddress}}&amp;lt;/td&amp;gt;
                        &amp;lt;/tr&amp;gt;
                        &amp;lt;tr&amp;gt;
                            &amp;lt;td style=&amp;quot;width:25%;&amp;quot;&amp;gt;Date and Time:&amp;lt;/td&amp;gt;
                            &amp;lt;td&amp;gt;{{=DeliveryDate}} from {{=DeliveryTime}}&amp;lt;/td&amp;gt;
                        &amp;lt;/tr&amp;gt;                        
                    &amp;lt;/table&amp;gt;                         
                    &amp;lt;/td&amp;gt;
            &amp;lt;/tr&amp;gt;
            &amp;lt;tr&amp;gt;
                &amp;lt;td&amp;gt;&amp;amp;nbsp;&amp;lt;/td&amp;gt;
            &amp;lt;/tr&amp;gt;                    
            &amp;lt;tr&amp;gt;
                &amp;lt;td class=&amp;quot;OrderHeader&amp;quot;&amp;gt;Items Ordered&amp;lt;/td&amp;gt;
            &amp;lt;/tr&amp;gt; 
            {{#if MainItems.length === 0}}
                &amp;lt;tr&amp;gt;
                    &amp;lt;td&amp;gt;No items selected&amp;lt;/td&amp;gt;
                &amp;lt;/tr&amp;gt;
            {{else}}
                {{#each MainItems tmpl=&amp;quot;#ItemsTemplate&amp;quot;}}
            {{/if}}
            &amp;lt;tr&amp;gt;
                &amp;lt;td&amp;gt;&amp;amp;nbsp;&amp;lt;/td&amp;gt;
            &amp;lt;/tr&amp;gt;   
            &amp;lt;tr&amp;gt;
                &amp;lt;td class=&amp;quot;OrderHeader&amp;quot;&amp;gt;Accessories Ordered&amp;lt;/td&amp;gt;
            &amp;lt;/tr&amp;gt; 
            {{#if AccessoryItems.length === 0}}
                &amp;lt;tr&amp;gt;
                    &amp;lt;td&amp;gt;No accessories selected&amp;lt;/td&amp;gt;
                &amp;lt;/tr&amp;gt;
            {{else}}
                {{#each AccessoryItems tmpl=&amp;quot;#ItemsTemplate&amp;quot;}}
            {{/if}}
            &amp;lt;tr&amp;gt;
                &amp;lt;td&amp;gt;&amp;amp;nbsp;&amp;lt;/td&amp;gt;
            &amp;lt;/tr&amp;gt;                          
        &amp;lt;/tbody&amp;gt;
    &amp;lt;/table&amp;gt;    
&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;script&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;

&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;script &lt;/span&gt;&lt;span style="color: red"&gt;id&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;ItemsTemplate&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;text/x-jquery-tmpl&amp;quot;&amp;gt;
    &lt;/span&gt;&amp;lt;tr&amp;gt;
        &amp;lt;td&amp;gt;
            {{=Name}} - {{=NumberOrdered}} ordered at $ {{=Price}} per item
        &amp;lt;/td&amp;gt;
    &amp;lt;/tr&amp;gt;
&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;script&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;
  

  &lt;div class="postsub"&gt;&amp;#160;&lt;/div&gt;

  &lt;div class="postsub"&gt;
    &lt;br /&gt;&lt;/div&gt;

  &lt;p class="postsub"&gt;The template is rendered to a div with an ID of OrderSummaryOutput using the following code.&amp;#160; The code first creates a JSON object by retrieving data from controls in a checkout wizard and then calls the the render() function provided by jsRender.&lt;/p&gt;

  &lt;p class="postsub"&gt;&amp;#160;&lt;/p&gt;

  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;function &lt;/span&gt;LoadApprovalDiv() {
    &lt;span style="color: blue"&gt;var &lt;/span&gt;subTotal = parseFloat($(&lt;span style="color: maroon"&gt;'#SubTotal'&lt;/span&gt;).text());
    $(&lt;span style="color: maroon"&gt;'#ClientSubTotal'&lt;/span&gt;).val(subTotal.toFixed(2));
    &lt;span style="color: blue"&gt;var &lt;/span&gt;salesTaxRate = parseFloat($(&lt;span style="color: maroon"&gt;'#SalesTaxRate'&lt;/span&gt;).val()) / 100;
    &lt;span style="color: blue"&gt;var &lt;/span&gt;salesTaxAmount = (subTotal * salesTaxRate) * .9;
    &lt;span style="color: blue"&gt;var &lt;/span&gt;deliveryFee = parseFloat($(&lt;span style="color: maroon"&gt;'#DeliveryFee'&lt;/span&gt;).val());
    &lt;span style="color: blue"&gt;var &lt;/span&gt;adminFee = ((subTotal + salesTaxAmount + deliveryFee) * .05);
    &lt;span style="color: blue"&gt;var &lt;/span&gt;total = (Round(subTotal) + Round(salesTaxAmount) + Round(deliveryFee) + 
                 Round(adminFee));
    $(&lt;span style="color: maroon"&gt;'#ClientTotal'&lt;/span&gt;).val(total);
    &lt;span style="color: blue"&gt;var &lt;/span&gt;deliveryAddress = $(&lt;span style="color: maroon"&gt;'#Delivery_Street'&lt;/span&gt;).val();
    &lt;span style="color: #006400"&gt;//See if they entered a suite
    &lt;/span&gt;&lt;span style="color: blue"&gt;if &lt;/span&gt;($(&lt;span style="color: maroon"&gt;'#Delivery_Suite'&lt;/span&gt;).val() != &lt;span style="color: maroon"&gt;''&lt;/span&gt;) deliveryAddress += &lt;span style="color: maroon"&gt;', Suite ' &lt;/span&gt;+ $(&lt;span style="color: maroon"&gt;'#Delivery_Suite'&lt;/span&gt;).val();
    deliveryAddress += &lt;span style="color: maroon"&gt;' ' &lt;/span&gt;+ $(&lt;span style="color: maroon"&gt;'#Delivery_City'&lt;/span&gt;).val() + &lt;span style="color: maroon"&gt;' ' &lt;/span&gt;+ $(&lt;span style="color: maroon"&gt;'#Delivery_StateID option:selected'&lt;/span&gt;).text() + &lt;span style="color: maroon"&gt;' ' &lt;/span&gt;+ 
                       $(&lt;span style="color: maroon"&gt;'#Delivery_Zip'&lt;/span&gt;).val();
    &lt;span style="color: blue"&gt;var &lt;/span&gt;creditCard = $(&lt;span style="color: maroon"&gt;'#Payment_CreditCardNumber'&lt;/span&gt;).val();
    &lt;span style="color: blue"&gt;var &lt;/span&gt;abbrCreditCard = &lt;span style="color: maroon"&gt;'*' &lt;/span&gt;+ creditCard.substring(creditCard.length - 5);

    &lt;span style="color: blue"&gt;var &lt;/span&gt;data= {
                   &lt;span style="color: maroon"&gt;'FinalSubTotal'  &lt;/span&gt;: subTotal.toFixed(2),
                   &lt;span style="color: maroon"&gt;'FinalSalesTax'  &lt;/span&gt;: salesTaxAmount.toFixed(2),
                   &lt;span style="color: maroon"&gt;'FinalTotal'     &lt;/span&gt;: total.toFixed(2),
                   &lt;span style="color: maroon"&gt;'DeliveryFee'    &lt;/span&gt;: deliveryFee.toFixed(2),
                   &lt;span style="color: maroon"&gt;'AdminFee'       &lt;/span&gt;: adminFee.toFixed(2),
                   &lt;span style="color: maroon"&gt;'DeliveryName'   &lt;/span&gt;: $(&lt;span style="color: maroon"&gt;'#Delivery_Name'&lt;/span&gt;).val(),
                   &lt;span style="color: maroon"&gt;'DeliveryAddress'&lt;/span&gt;: deliveryAddress,
                   &lt;span style="color: maroon"&gt;'CreditCard'     &lt;/span&gt;: abbrCreditCard,
                   &lt;span style="color: maroon"&gt;'DeliveryDate'   &lt;/span&gt;: $(&lt;span style="color: maroon"&gt;'#Delivery_DeliveryDate'&lt;/span&gt;).val(),
                   &lt;span style="color: maroon"&gt;'DeliveryTime'   &lt;/span&gt;: $(&lt;span style="color: maroon"&gt;'#Delivery_DeliveryTime option:selected'&lt;/span&gt;).text(),
                   &lt;span style="color: maroon"&gt;'MainItems'      &lt;/span&gt;: GenerateData(&lt;span style="color: maroon"&gt;'Main'&lt;/span&gt;),
                   &lt;span style="color: maroon"&gt;'AccessoryItems' &lt;/span&gt;: GenerateData(&lt;span style="color: maroon"&gt;'Accessory'&lt;/span&gt;)
               };

    &lt;span style="color: #006400"&gt;//jQuery template example
    &lt;/span&gt;$(&lt;span style="color: maroon"&gt;&amp;quot;#OrderSummaryOutput&amp;quot;&lt;/span&gt;).html($(&lt;span style="color: maroon"&gt;&amp;quot;#OrderSummaryTemplate&amp;quot;&lt;/span&gt;).render(data));
}&lt;br /&gt;&lt;/pre&gt;
  

  &lt;p class="postsub"&gt;
    &lt;br /&gt;&lt;/p&gt;

  &lt;p class="postsub"&gt;If you’re working with dynamic web applications that leverage jQuery and AJAX you’ll find that jsRender can significantly increase your productivity and eliminate a lot of code that you’d normally have to write. Although jsRender is still new (at the time this post was written anyway), it’s definitely worth looking into more. In future posts I’ll discuss a companion to jsRender called jsView that provides client-side data binding capabilities.&lt;/p&gt;

  &lt;p class="postsub"&gt;&amp;#160;&lt;/p&gt;

  &lt;p class="postsub"&gt;&amp;#160;&lt;/p&gt;

  &lt;p class="postsub"&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/Logo_702D5F601_005E8AA4.jpg"&gt;&lt;img title="Logo_702D5F60[1]" border="0" alt="Logo_702D5F60[1]" src="http://weblogs.asp.net/blogs/dwahlin/Logo_702D5F601_thumb_26C06DEF.jpg" width="240" height="57" /&gt;&lt;/a&gt;&lt;/p&gt;

  &lt;p class="postsub"&gt;If you or your company is interested in training, consulting or mentoring on jQuery, HTML5,&amp;#160; or .NET technologies please visit &lt;a href="http://www.thewahlingroup.com/"&gt;http://www.thewahlingroup.com&lt;/a&gt; for more information. We’ve provided training, consulting and mentoring services to some of the largest companies in the world and would enjoy sharing our knowledge and real-world lessons learned with you.&lt;/p&gt;
&lt;/div&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8071151" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/JSON/default.aspx">JSON</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/HTML5/default.aspx">HTML5</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/JavaScript/default.aspx">JavaScript</category></item><item><title>A Few of My Favorite HTML5 and CSS3 Online Tools</title><link>http://weblogs.asp.net/dwahlin/archive/2011/11/17/a-few-of-my-favorite-html5-and-css3-online-tools.aspx</link><pubDate>Fri, 18 Nov 2011 07:14:39 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8062864</guid><dc:creator>dwahlin</dc:creator><slash:comments>8</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=8062864</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2011/11/17/a-few-of-my-favorite-html5-and-css3-online-tools.aspx#comments</comments><description>&lt;p&gt;I really enjoy coding up HTML5, CSS3, and JavaScript applications but there are some things that I’m better off writing with the help of a development tool. For example, CSS3 gradients aren’t exactly the most fun thing to write by hand and the same could be said for animations, transforms, or styles that require various vendor extensions. There are a lot of online tools that can simplify building HTML5/CSS3 sites and increase productivity in the process so I thought I’d put together a post on a few of my favorites tools.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;HTML5 Boilerplate&lt;/h2&gt;  &lt;p&gt;&lt;a href="http://html5boilerplate.com" target="_blank"&gt;HTML5 Boilerplate&lt;/a&gt; provides a great way to get started building HTML5 sites. It includes many best practices out of the box and even includes a few tricks that many people don’t even know about. The custom download option allows you to pick the features that you want to include in the files that’s generated. You can &lt;a href="http://weblogs.asp.net/dwahlin/archive/2011/06/05/getting-started-using-html5-boilerplate.aspx" target="_blank"&gt;read more about it here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&lt;a href="http://html5boilerplate.com" target="_blank"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Clipboard01" border="0" alt="Clipboard01" src="http://weblogs.asp.net/blogs/dwahlin/Clipboard01_5A2FF891.png" width="654" height="229" /&gt;&lt;/a&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;Initializr&lt;/h2&gt;  &lt;p&gt;Although HTML5 Boilerplate provides a great foundation for starting HTML5 sites, it focuses on providing a starting shell structure (namely an html page, JavaScript files, and a CSS stylesheet) and doesn’t include much in the way of page content to get started with. &lt;a href="http://www.initializr.com" target="_blank"&gt;Initializer&lt;/a&gt; builds on HTML5 Boilerplate and provides an initial test page that can be tweaked to meet your needs. It also provides several different customization options to include/exclude features.     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.initializr.com" target="_blank"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Clipboard02" border="0" alt="Clipboard02" src="http://weblogs.asp.net/blogs/dwahlin/Clipboard02_244B0377.png" width="654" height="321" /&gt;&lt;/a&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;CSS3 Maker&lt;/h2&gt;  &lt;p&gt;CSS3 provides a lot of great features ranging from gradient support to rounded corners. Although many of the features are fairly straightforward there are some that are pretty involved such as gradients, animations, and really any styles that require custom vendor extensions to use across browsers. Sure, you can type everything by hand, but sites such as &lt;a href="http://www.css3maker.com/" target="_blank"&gt;CSS3 Maker&lt;/a&gt; provide a visual way to generate CSS3 styles.&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&lt;a href="http://www.css3maker.com/" target="_blank"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Clipboard03" border="0" alt="Clipboard03" src="http://weblogs.asp.net/blogs/dwahlin/Clipboard03_7F4D42FD.png" width="655" height="414" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;CSS3, Please!&lt;/h2&gt;  &lt;p&gt;&lt;a href="http://css3please.com/" target="_blank"&gt;CSS3, Please!&lt;/a&gt; is a code generation tool that can be used to generate cross-browser CSS3 styles quickly and easily. All of the main things you can do with CSS3 are available including a clever way to visually generate CSS3 transform styles.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://css3please.com/" target="_blank"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Clipboard09" border="0" alt="Clipboard09" src="http://weblogs.asp.net/blogs/dwahlin/Clipboard09_16E7F67A.png" width="659" height="310" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&lt;a href="http://css3please.com/" target="_blank"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Clipboard10" border="0" alt="Clipboard10" src="http://weblogs.asp.net/blogs/dwahlin/Clipboard10_66FA28E2.png" width="659" height="222" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;Ultimate CSS Gradient Generator&lt;/h2&gt;  &lt;p&gt;CSS3 Maker (above) has a gradient generator built-in but my favorite tool for creating CSS3 gradients is the &lt;a href="http://www.colorzilla.com/gradient-editor/" target="_blank"&gt;Ultimate CSS Gradient Generator&lt;/a&gt;. If you’ve created gradients in tools like Photoshop then you’ll love what this tool has to offer especially since it makes it extremely straightforward to work with different gradient stops.     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.colorzilla.com/gradient-editor/" target="_blank"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Clipboard04" border="0" alt="Clipboard04" src="http://weblogs.asp.net/blogs/dwahlin/Clipboard04_5AF838AE.png" width="658" height="573" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;    &lt;br /&gt;&lt;/p&gt;  &lt;h2&gt;@font-face Fonts&lt;/h2&gt;  &lt;p&gt;Although @font-face has been available for awhile, I think fonts are cool and wanted to mention a site that provides a lot of font choices. When used correctly fonts can really enhance a page and when used incorrectly (think Comic Sans) they can absolutely ruin a page. Several sites exist that provide fonts that can be used with @font-face definitions in CSS style sheets. One of my favorites is &lt;a href="http://www.fontsquirrel.com/fontface" target="_blank"&gt;Font Squirrel&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.fontsquirrel.com/fontface" target="_blank"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Clipboard11" border="0" alt="Clipboard11" src="http://weblogs.asp.net/blogs/dwahlin/Clipboard11_6103015F.png" width="663" height="322" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;    &lt;br /&gt;&lt;/p&gt;  &lt;h2&gt;HTML5 &amp;amp; CSS3 Support and Tests&lt;/h2&gt;  &lt;p&gt;Interested in knowing what HTML5 and CSS3 features a given browser supports? Want to know how various browsers stack up with each other as far as HTML5/CSS3 support. Look no further than the &lt;a href="http://www.findmebyip.com/litmus" target="_blank"&gt;HTML5 &amp;amp; CSS3 Support&lt;/a&gt; page or the &lt;a href="http://html5test.com/" target="_blank"&gt;HTML5 Test&lt;/a&gt; page.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.findmebyip.com/litmus" target="_blank"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Clipboard05" border="0" alt="Clipboard05" src="http://weblogs.asp.net/blogs/dwahlin/Clipboard05_221DDEE1.png" width="669" height="273" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://html5test.com/" target="_blank"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_0EFCB235.png" width="671" height="310" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;    &lt;br /&gt;&lt;/p&gt;  &lt;h2&gt;CSS3 Easing Animation Tool&lt;/h2&gt;  &lt;p&gt;CSS3 animations aren’t widely supported across browsers right now (I’m not really using them at this point) but they do offer a lot of promise. Creating easings for animations can definitely be a challenge but they’re something that are critical for adding that “professional touch” to your animations. Fortunately you can use the &lt;a href="http://matthewlein.com/ceaser/" target="_blank"&gt;Ceaser CSS Easing Animation Tool&lt;/a&gt; to simplify the process and handle animation easing with…...ease.&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&lt;a href="http://matthewlein.com/ceaser/" target="_blank"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Clipboard07" border="0" alt="Clipboard07" src="http://weblogs.asp.net/blogs/dwahlin/Clipboard07_07050FD3.png" width="675" height="524" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;There are several other online tools that I like but these are some of the ones I find myself using the most. If you have any favorite online tools that simplify working with HTML5 or CSS3 let me know.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.thewahlingroup.com/"&gt;&lt;img title="Logo" border="0" alt="Logo" src="http://weblogs.asp.net/blogs/dwahlin/Logo_702D5F60.jpg" width="240" height="57" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;For more information about onsite or online training, mentoring and consulting solutions for HTML5, jQuery, .NET, SharePoint or Silverlight please visit &lt;a href="http://www.thewahlingroup.com"&gt;http://www.thewahlingroup.com&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8062864" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/HTML5/default.aspx">HTML5</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/CSS/default.aspx">CSS</category></item><item><title>Detecting HTML5/CSS3 Features using Modernizr</title><link>http://weblogs.asp.net/dwahlin/archive/2011/11/16/detecting-html5-css3-features-using-modernizr.aspx</link><pubDate>Thu, 17 Nov 2011 07:05:24 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8061174</guid><dc:creator>dwahlin</dc:creator><slash:comments>5</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=8061174</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2011/11/16/detecting-html5-css3-features-using-modernizr.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_54E7071C.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 20px 15px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" align="left" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_7F533839.png" width="244" height="78" /&gt;&lt;/a&gt;HTML5, CSS3, and related technologies such as canvas and web sockets bring a lot of useful new features to the table that can take Web applications to the next level. These new technologies allow applications to be built using only HTML, CSS, and JavaScript allowing them to be viewed on a variety of form factors including tablets and phones. Although HTML5 features offer a lot of promise, it’s not realistic to develop applications using the latest technologies without worrying about supporting older browsers in the process. If history has taught us anything it’s that old browsers stick around for years and years which means developers have to deal with backward compatibility issues. This is especially true when deploying applications to the Internet that target the general public. This begs the question, “How do you move forward with HTML5 and CSS3 technologies while gracefully handling unsupported features in older browsers?”&lt;/p&gt;  &lt;p&gt;Although you can write code by hand to detect different HTML5 and CSS3 features, it’s not always straightforward. For example, to check for canvas support you need to write code similar to the following:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;script&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &lt;/span&gt;window.onload = &lt;span style="color: blue"&gt;function &lt;/span&gt;() {
        &lt;span style="color: blue"&gt;if &lt;/span&gt;(canvasSupported()) {
            alert(&lt;span style="color: maroon"&gt;'canvas supported'&lt;/span&gt;);
        }
    };
        
    &lt;span style="color: blue"&gt;function &lt;/span&gt;canvasSupported() {
        &lt;span style="color: blue"&gt;var &lt;/span&gt;canvas = document.createElement(&lt;span style="color: maroon"&gt;'canvas'&lt;/span&gt;);
        &lt;span style="color: blue"&gt;return &lt;/span&gt;(canvas.getContext &amp;amp;&amp;amp; canvas.getContext(&lt;span style="color: maroon"&gt;'2d'&lt;/span&gt;));
    }
&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;script&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;If you want to check for local storage support the following check can be made. It’s more involved than it should be due to a bug in older versions of Firefox.&lt;/p&gt;

&lt;p&gt;&lt;span style="color: blue"&gt;&lt;/span&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;script&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &lt;/span&gt;window.onload = &lt;span style="color: blue"&gt;function &lt;/span&gt;() {
        &lt;span style="color: blue"&gt;if &lt;/span&gt;(localStorageSupported()) {
            alert(&lt;span style="color: maroon"&gt;'local storage supported'&lt;/span&gt;);
        }
    };

    &lt;span style="color: blue"&gt;function &lt;/span&gt;localStorageSupported() {
        &lt;span style="color: blue"&gt;try &lt;/span&gt;{
            &lt;span style="color: blue"&gt;return &lt;/span&gt;(&lt;span style="color: maroon"&gt;'localStorage' &lt;/span&gt;&lt;span style="color: blue"&gt;in &lt;/span&gt;window &amp;amp;&amp;amp; window[&lt;span style="color: maroon"&gt;'localStorage'&lt;/span&gt;] != &lt;span style="color: blue"&gt;null&lt;/span&gt;);
        }
        &lt;span style="color: blue"&gt;catch&lt;/span&gt;(e) {}
        &lt;span style="color: blue"&gt;return false&lt;/span&gt;;
    }
&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;script&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;
  &lt;br /&gt;Looking through the previous examples you can see that there’s more than meets the eye when it comes to checking browsers for HTML5 and CSS3 features. It takes a lot of work to test every possible scenario and every version of a given browser. Fortunately, you don’t have to resort to writing custom code to test what HTML5/CSS3 features a given browser supports. By using a script library called Modernizr you can add checks for different HTML5/CSS3 features into your pages with a minimal amount of code on your part. Let’s take a look at some of the key features Modernizr offers.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h2&gt;Getting Started with Modernizr&lt;/h2&gt;

&lt;p&gt;The first time I heard the name “Modernizr” I thought it “modernized” older browsers by added missing functionality. In reality, Modernizr doesn’t actually handle adding missing features or “modernizing” older browsers. The Modernizr website states, “The name Modernizr actually stems from the goal of modernizing our development practices (and ourselves)”. Because it relies on feature detection rather than browser sniffing (a common technique used in the past – that never worked that great), Modernizr definitely provides a more modern way to test features that a browser supports and can even handle loading additional scripts called shims or polyfills that fill in holes that older browsers may have. It’s a great tool to have in your arsenal if you’re a web developer.&lt;/p&gt;

&lt;p&gt;Modernizr is available at &lt;a href="http://modernizr.com"&gt;http://modernizr.com&lt;/a&gt;. Two different types of scripts are available including a development script and custom production script. To generate a production script, the site provides a custom script generation tool rather than providing a single script that has everything under the sun for HTML5/CSS3 feature detection. Using the script generation tool you can pick the specific test functionality that you need and ignore everything that you don’t need. That way the script is kept as small as possible. An example of the custom script download screen is shown next. Notice that specific CSS3, HTML5, and related feature tests can be selected.

  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_4C8331C5.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_36B94968.png" width="690" height="533" /&gt;&lt;/a&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;Once you’ve downloaded your custom script you can add it into your web page using the standard &amp;lt;script&amp;gt; element and you’re ready to start using Modernizr.&lt;/p&gt;

&lt;p&gt;
  &lt;br /&gt;

  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;script &lt;/span&gt;&lt;span style="color: red"&gt;src&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Scripts/Modernizr.js&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;script&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;
  &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h2&gt;Modernizr and the HTML Element&lt;/h2&gt;

&lt;p&gt;Once you’ve add a script reference to Modernizr in a page it’ll go to work for you immediately. In fact, by adding the script several different CSS classes will be added to the page’s &amp;lt;html&amp;gt; element at runtime. These classes define what features the browser supports and what features it doesn’t support. Features that aren’t supported get a class name of “no-FeatureName”, for example “no-flexbox”. Features that are supported get a CSS class name based on the feature such as “canvas” or “websockets”. An example of classes added when running a page in Chrome is shown next:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;
  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;html &lt;/span&gt;&lt;span style="color: red"&gt;class&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot; js flexbox canvas canvastext webgl no-touch geolocation postmessage 
              websqldatabase indexeddb hashchange history draganddrop websockets rgba hsla 
              multiplebgs backgroundsize borderimage borderradius boxshadow textshadow opacity 
              cssanimations csscolumns cssgradients cssreflections csstransforms csstransforms3d 
              csstransitions fontface generatedcontent video audio localstorage sessionstorage webworkers 
              applicationcache svg inlinesvg smil svgclippaths&amp;quot;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;
  

  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;Here’s an example of what the &amp;lt;html&amp;gt; element looks like at runtime with Internet Explorer 9:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;html &lt;/span&gt;&lt;span style="color: red"&gt;class&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot; js no-flexbox canvas canvastext no-webgl no-touch geolocation 
              postmessage no-websqldatabase no-indexeddb hashchange no-history draganddrop no-websockets 
              rgba hsla multiplebgs backgroundsize no-borderimage borderradius boxshadow no-textshadow 
              opacity no-cssanimations no-csscolumns no-cssgradients no-cssreflections csstransforms 
              no-csstransforms3d no-csstransitions fontface generatedcontent video audio localstorage 
              sessionstorage no-webworkers no-applicationcache svg inlinesvg smil svgclippaths&amp;quot;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;When using Modernizr it’s a common practice to define an &amp;lt;html&amp;gt; element in your page with a &lt;strong&gt;no-js&lt;/strong&gt; class added as shown next:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;html &lt;/span&gt;&lt;span style="color: red"&gt;class&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;no-js&amp;quot;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;You’ll see starter projects such as HTML5 Boilerplate (&lt;a href="http://html5boilerplate.com"&gt;http://html5boilerplate.com&lt;/a&gt;) or Initializr (&lt;a href="http://initializr.com"&gt;http://initializr.com&lt;/a&gt;) follow this approach (see my &lt;a href="http://weblogs.asp.net/dwahlin/archive/2011/06/05/getting-started-using-html5-boilerplate.aspx" target="_blank"&gt;previous post&lt;/a&gt; for more information on HTML5 Boilerplate). By adding the &lt;strong&gt;no-js&lt;/strong&gt; class it’s easy to tell if a browser has JavaScript enabled or not. If JavaScript is disabled then &lt;strong&gt;no-js&lt;/strong&gt; will stay on the &amp;lt;html&amp;gt; element. If JavaScript is enabled, &lt;strong&gt;no-js&lt;/strong&gt; will be removed by Modernizr and a &lt;strong&gt;js&lt;/strong&gt; class will be added along with other classes that define supported/unsupported features. &lt;/p&gt;

&lt;p&gt;
  &lt;br /&gt;&lt;/p&gt;

&lt;h2&gt;Working with HTML5 and CSS3 Features&lt;/h2&gt;

&lt;p&gt;You can use the CSS classes added to the &amp;lt;html&amp;gt; element directly in your CSS files to determine what style properties to use based upon the features supported by a given browser. For example, the following CSS can be used to render a box shadow for browsers that support that feature and a simple border for browsers that don’t support the feature:
  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;
  &lt;br /&gt;

  &lt;pre class="code"&gt;&lt;span style="color: maroon"&gt;.boxshadow #MyContainer &lt;/span&gt;{
    &lt;span style="color: red"&gt;border&lt;/span&gt;: &lt;span style="color: blue"&gt;none&lt;/span&gt;;
    &lt;span style="color: red"&gt;-webkit-box-shadow&lt;/span&gt;: &lt;span style="color: blue"&gt;#666 1px 1px 1px&lt;/span&gt;;
    &lt;span style="color: red"&gt;-moz-box-shadow&lt;/span&gt;: &lt;span style="color: blue"&gt;#666 1px 1px 1px&lt;/span&gt;;
}
    
&lt;span style="color: maroon"&gt;.no-boxshadow #MyContainer &lt;/span&gt;{
    &lt;span style="color: red"&gt;border&lt;/span&gt;: &lt;span style="color: blue"&gt;2px solid black&lt;/span&gt;;
}&lt;br /&gt;&lt;/pre&gt;
  &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;If a browser supports box-shadows the boxshadow CSS class will be added to the &amp;lt;html&amp;gt; element by Modernizr. It can then be associated with a given element. This example associates the boxshadow class with a div with an id of MyContainer. If the browser doesn’t support box shadows then the no-boxshadow class will be added to the &amp;lt;html&amp;gt; element and it can be used to render a standard border around the div. This provides a great way to leverage new CSS3 features in supported browsers while providing a graceful fallback for older browsers.&lt;/p&gt;

&lt;p&gt;
  &lt;br /&gt;In addition to using the CSS classes that Modernizr provides on the &amp;lt;html&amp;gt; element, you also use a global Modernizr object that’s created. This object exposes different properties that can be used to detect the availability of specific HTML5 or CSS3 features. For example, the following code can be used to detect canvas and local storage support. You can see that the code is much simpler than the code shown at the beginning of this post. It also has the added benefit of being tested by a large community of web developers around the world running a variety of browsers.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;$(document).ready(&lt;span style="color: blue"&gt;function &lt;/span&gt;() {

    &lt;span style="color: blue"&gt;if &lt;/span&gt;(Modernizr.canvas) {
        &lt;span style="color: #006400"&gt;//Add canvas code
    &lt;/span&gt;}

    &lt;span style="color: blue"&gt;if &lt;/span&gt;(Modernizr.localstorage) {
        &lt;span style="color: #006400"&gt;//Add local storage code
    &lt;/span&gt;}

});&lt;br /&gt;&lt;/pre&gt;






&lt;p&gt;The global Modernizr object can also be used to test for the presence of CSS3 features. The following code shows how to test support for border-radius and CSS transforms:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;$(document).ready(&lt;span style="color: blue"&gt;function &lt;/span&gt;() {

    &lt;span style="color: blue"&gt;if &lt;/span&gt;(Modernizr.borderradius) {
        $(&lt;span style="color: maroon"&gt;'#MyDiv'&lt;/span&gt;).addClass(&lt;span style="color: maroon"&gt;'borderRadiusStyle'&lt;/span&gt;);
    }
        
    &lt;span style="color: blue"&gt;if &lt;/span&gt;(Modernizr.csstransforms) {
        $(&lt;span style="color: maroon"&gt;'#MyDiv'&lt;/span&gt;).addClass(&lt;span style="color: maroon"&gt;'transformsStyle'&lt;/span&gt;);
    }

});&lt;br /&gt;&lt;/pre&gt;


&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Several other CSS3 feature tests can be performed such as support for opacity, rgba, text-shadow, CSS animations, CSS transitions, multiple backgrounds, and more. A complete list of supported HTML5 and CSS3 tests that Modernizr supports can be found at &lt;a href="http://www.modernizr.com/docs"&gt;http://www.modernizr.com/docs&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h2&gt;Loading Scripts using Modernizr&lt;/h2&gt;

&lt;p&gt;In cases where a browser doesn’t support a specific feature you can either provide a graceful fallback or load a shim/polyfill script to fill in missing functionality where appropriate (more information about shims/polyfills can be found at &lt;a href="https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-Browser-Polyfills"&gt;https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-Browser-Polyfills&lt;/a&gt;). Modernizr has a built-in script loader that can be used to test for a feature and then load a script if the feature isn’t available. The script loader is built-into Modernizr and is also available as a standalone yepnope script (&lt;a href="http://yepnopejs.com"&gt;http://yepnopejs.com&lt;/a&gt;). It’s extremely easy to get started using the script loader and it can really simplify the process of loading scripts based on the availability of a particular browser feature.&lt;/p&gt;

&lt;p&gt;To load scripts dynamically you can use Modernizr’s &lt;strong&gt;load()&lt;/strong&gt; function which accepts properties defining the feature to test (test property), the script to load if the test succeeds (yep property), the script to load if the test fails (nope property), and a script to load regardless of if the test succeeds or fails (both property). An example of using load() with these properties is show next:

  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;
  &lt;br /&gt;

  &lt;pre class="code"&gt;Modernizr.load({
    test: Modernizr.canvas,&lt;br /&gt;    yep:  &lt;span style="color: maroon"&gt;'html5CanvasAvailable.js’,&lt;/span&gt;
    nope: &lt;span style="color: maroon"&gt;'excanvas.js’, &lt;br /&gt;    &lt;font color="#000000"&gt;both:&lt;/font&gt; &lt;span style="color: maroon"&gt;'myCustomScript.js'&lt;/span&gt; 
&lt;/span&gt;});&lt;br /&gt;&lt;/pre&gt;
  &lt;/p&gt;

&lt;p&gt;In this example Modernizr is used to not only load scripts but also to test for the presence of the canvas feature. If the target browser supports the HTML5 canvas then the html5CanvasAvailable.js script will be loaded along with the myCustomScript.js script (use of the yep property in this example is a bit contrived – it was added simply to demonstrate how the property can be used in the load() function). Otherwise, a polyfill script named excanvas.js will be loaded to add missing canvas functionality for Internet Explorer versions prior to 9. Once excanvas.js is loaded the myCustomScript.js script will be loaded.&lt;/p&gt;

&lt;p&gt;Because Modernizr handles loading scripts, you can also use it in creative ways. For example, you can use it to load local scripts when a 3rd party Content Delivery Network (CDN) such as one provided by Google or Microsoft is unavailable for whatever reason. The Modernizr documentation provides the following example that demonstrates the process for providing a local fallback for jQuery when a CDN is down:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;
  &lt;pre class="code"&gt;Modernizr.load([
    {
        load: &lt;span style="color: maroon"&gt;'//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.js'&lt;/span&gt;,
        complete: &lt;span style="color: blue"&gt;function &lt;/span&gt;() {
            &lt;span style="color: blue"&gt;if &lt;/span&gt;(!window.jQuery) {
                Modernizr.load(&lt;span style="color: maroon"&gt;'js/libs/jquery-1.6.4.min.js'&lt;/span&gt;);
            }
        }
    },
    {
        &lt;span style="color: #006400"&gt;// This will wait for the fallback to load and
        // execute if it needs to.
        &lt;/span&gt;load: &lt;span style="color: maroon"&gt;'needs-jQuery.js'
    &lt;/span&gt;}
]);&lt;br /&gt;&lt;/pre&gt;
  This code attempts to load jQuery from the Google CDN first. Once the script is downloaded (or if it fails) the function associated with complete will be called. The function checks to make sure that the jQuery object is available and if it’s not Modernizr is used to load a local jQuery script. After all of that occurs a script named needs-jQuery.js will be loaded. 

  &lt;br /&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;If you’re building applications that use some of the latest and greatest features available in HTML5 and CSS3 then Modernizr is an essential tool. By using it you can reduce the amount of custom code required to test for browser features and provide graceful fallbacks or even load shim/polyfill scripts for older browsers to help fill in missing functionality.&amp;#160; &lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8061174" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/HTML5/default.aspx">HTML5</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/CSS/default.aspx">CSS</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Modernizr/default.aspx">Modernizr</category></item><item><title>New Pluralsight Course: Introduction to Building Windows 8 Metro Applications</title><link>http://weblogs.asp.net/dwahlin/archive/2011/11/03/new-pluralsight-course-introduction-to-building-windows-8-metro-applications.aspx</link><pubDate>Thu, 03 Nov 2011 07:37:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8029885</guid><dc:creator>dwahlin</dc:creator><slash:comments>2</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=8029885</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2011/11/03/new-pluralsight-course-introduction-to-building-windows-8-metro-applications.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_6AFFCDCB.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_680A6918.png" width="201" height="60" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Over the past few months I’ve been working on a new Windows 8 Metro app development course for &lt;a href="http://www.pluralsight.com" target="_blank"&gt;Pluralsight&lt;/a&gt; with my good friend &lt;a href="http://johnpapa.net" target="_blank"&gt;John Papa&lt;/a&gt;. We had a lot of fun making the course together and diving into key concepts that you need to know to build XAML/C# or HTML/JavaScript Metro apps. Here’s the course description, a sample video from the HTML/JavaScript Metro app section of the course (click the image below), and the table of contents for the course. If you have a Pluralsight subscription you can &lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=win8-intro" target="_blank"&gt;view the complete course here&lt;/a&gt;.    &lt;br /&gt;    &lt;br /&gt;&lt;/p&gt;  &lt;h2&gt;Introduction to Building Windows 8 Metro Applications&lt;/h2&gt;  &lt;p&gt;Windows 8 Metro style apps provide a new opportunity for developers to interact with users and provide a more immersive experience on the desktop or on touch devices. This course covers fundamentals you need to know to get started building Metro apps quickly using Visual Studio 11. Topics covered include an overview of Windows 8 and Metro app features as well as key features that you need to know to build HTML/JavaScript or XAML/C# Metro apps.    &lt;br /&gt;&lt;/p&gt;  &lt;h3&gt;Sample Video: Handling Events in HTML/JavaScript Metro Apps&lt;/h3&gt;    &lt;p&gt;

&lt;object style="height: 400px; width: 512px"&gt;&lt;param 

name="movie" value="http://www.youtube.com/v/bFOrLc-OY4k?version=3&amp;feature=player_profilepage&amp;hd=1"&gt;&lt;param 

name="allowFullScreen" value="true"&gt;&lt;param 

name="allowScriptAccess" value="always"&gt;&lt;embed 

src="http://www.youtube.com/v/bFOrLc-OY4k?version=3&amp;feature=player_profilepage&amp;hd=1" 

type="application/x-shockwave-flash" 

allowfullscreen="true" allowScriptAccess="always" 

width="512" height="400"&gt;&lt;/object&gt;


&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;&lt;/em&gt;&lt;/p&gt;  &lt;h3&gt;Table of Contents&lt;/h3&gt;  &lt;p&gt;&lt;em&gt;&lt;/em&gt;&lt;/p&gt;  &lt;table class="linkContainer" width="454"&gt;&lt;thead&gt;&lt;/thead&gt;&lt;tbody&gt;     &lt;tr style="cursor: pointer" class="module" onclick="toggleModule();"&gt;       &lt;td style="padding-left: 0px" class="title tocModule"&gt;         &lt;div class="playButton"&gt;&lt;span style="margin-left: 10px"&gt;&lt;strong&gt;Introduction to Building Windows 8 Metro&amp;#160; &lt;br /&gt;&amp;#160; Applications&lt;/strong&gt;&lt;/span&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Introduction&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Windows 8 Start Screen&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Windows 8 Start Screen Demo&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Metro UI&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Metro UI Demo&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;App Snapping&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;App Snapping Demo&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Charms&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Charms Demo&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;App Bar&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;App Bar Demo&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Summary&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr style="cursor: pointer" class="module" onclick="toggleModule();"&gt;       &lt;td style="padding-left: 0px" class="title tocModule"&gt;         &lt;div class="playButton"&gt;&lt;strong&gt;&amp;#160;&lt;span style="margin-left: 10px"&gt;A Lap Around the Metro Application Framework&lt;/span&gt;&lt;/strong&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Introduction&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Metro App Framework&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Metro App Framework Demo&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Development Choices&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;App Lifecycle&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;App Lifecycle Demo&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Controls&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Controls Demo&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Visual Studio Templates&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Visual Studio HTML/JavaScript Templates Demo&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Visual Studio XAML Templates Demo&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Hello World Intro&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Hello World HTML/JavaScript Demo&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Hello World XAML/C# Demo&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Summary&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr style="cursor: pointer" class="module" onclick="toggleModule();"&gt;       &lt;td style="padding-left: 0px" class="title tocModule"&gt;         &lt;div class="playButton"&gt;&amp;#160;&lt;span style="margin-left: 10px"&gt;&lt;strong&gt;Getting Started Building HTML/JavaScript Metro                &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Apps&lt;/strong&gt;&lt;/span&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Introduction&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Introduction to HTML Metro Apps&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Metro Apps Demo&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;UI Surfaces, Layout, and Navigation&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Message Dialog Demo&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Fixed Layout Demo&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Fluid Layout Demo&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Fragment Navigation Demo&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;IFrame Navigation Demo&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Controls&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Controls Demo&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Handling Events&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Event Lifecycle Demo&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Handling Events Demo&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Data Binding&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Data Binding Demo&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Styles&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Style Demo&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Expression Blend Demo&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Animation&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Animation Demo&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Adding Animations to an App Demo&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Summary&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr style="cursor: pointer" class="module" onclick="toggleModule();"&gt;       &lt;td style="padding-left: 0px" class="title tocModule"&gt;         &lt;div class="playButton"&gt;&amp;#160;&lt;span style="margin-left: 10px"&gt;&lt;strong&gt;Getting Started Building XAML/C# Metro Apps&lt;/strong&gt;&lt;/span&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Introduction&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Intro to XAML Metro Apps&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Intro to XAML Metro Apps Demo&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Controls and Visual Studio 11 Express Designer&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Controls and Designer Demo&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Events&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Events Demo&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Data Binding&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Data Binding Demos&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Styles&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Styles Demo&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Light and Dark Styles Demo&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Animation&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Animation Demos&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;Summary&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;

Additional courses that I've published for Pluralsight include:
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://www.pluralsight-training.net/microsoft/courses/TableOfContents?courseName=aspdotnet-webforms4-intro" title="
    Building Application with ASP.NET 4 WebForms is a course designed to get you up and running with ASP.NET WebForms. The modules in the course will cover everything from setting up a development environment to deploying to a live web site. In between we'll drill into the details of server controls, data binding and validation, user controls, security, Ajax features, and persisting data to SQL Server. 
  "&gt;Introduction to ASP.NET 4 WebForms&lt;/a&gt;
 &lt;/li&gt;
&lt;li&gt;                     
                        &lt;a href="http://www.pluralsight-training.net/microsoft/courses/TableOfContents?courseName=jquery-fundamentals" title="
    This course will guide you through the features of the 
	jQuery &amp;quot;write less, do more&amp;quot; library. 	We'll demonstrate how 
	you can use jQuery to select and manipulate DOM elements, 
	process events, and build a compelling user interface for web clients. 
  "&gt;jQuery Fundamentals&lt;/a&gt;
  &lt;/li&gt;
&lt;li&gt;
                        &lt;a href="http://www.pluralsight-training.net/microsoft/courses/TableOfContents?courseName=sharepoint-features-and-solutions-by-example" title="Learn how to deploy new features to SharePoint 2007 by packaging them as 'features' and then rolling those features into 'solutions'.
  "&gt;SharePoint 2007 Features and Solutions by Example&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.thewahlingroup.com/"&gt;&lt;img title="Logo" border="0" alt="Logo" src="http://weblogs.asp.net/blogs/dwahlin/Logo_702D5F60.jpg" width="240" height="57" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;For more information about onsite or online training, mentoring and consulting solutions for HTML5, jQuery, .NET, SharePoint or Silverlight please visit &lt;a href="http://www.thewahlingroup.com"&gt;http://www.thewahlingroup.com&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8029885" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/HTML5/default.aspx">HTML5</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/WinRT/default.aspx">WinRT</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Windows+8/default.aspx">Windows 8</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Metro+Apps/default.aspx">Metro Apps</category></item><item><title>HTML5, JavaScript, and Windows 8 Metro Talk Slides from DevConnections Las Vegas</title><link>http://weblogs.asp.net/dwahlin/archive/2011/11/02/html5-javascript-and-windows-8-metro-talk-slides-from-devconnections-las-vegas.aspx</link><pubDate>Thu, 03 Nov 2011 06:35:30 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8029819</guid><dc:creator>dwahlin</dc:creator><slash:comments>4</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=8029819</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2011/11/02/html5-javascript-and-windows-8-metro-talk-slides-from-devconnections-las-vegas.aspx#comments</comments><description>&lt;p&gt;&lt;img alt="DevConnections Logo" src="http://devconnections.com/img/logo-devconnections.png" /&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;I had a great time at DevConnections Las Vegas this year and really enjoyed hanging out with existing friends as well as making some new friends. Thanks to everyone who attended my workshop and sessions. The slides from the different sessions are available to download below (click an image).&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dl.dropbox.com/u/6037348/Conferences/DevConnectionsFall2011.zip"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_2AAD0215.png" width="285" height="215" /&gt;&lt;/a&gt;&lt;a href="http://dl.dropbox.com/u/6037348/Conferences/DevConnectionsFall2011.zip"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_77DCFBA0.png" width="285" height="214" /&gt;&lt;/a&gt;&lt;a href="http://dl.dropbox.com/u/6037348/Conferences/DevConnectionsFall2011.zip"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_28FC3641.png" width="283" height="213" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.thewahlingroup.com/"&gt;&lt;img title="Logo" border="0" alt="Logo" src="http://weblogs.asp.net/blogs/dwahlin/Logo_702D5F60.jpg" width="240" height="57" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;For more information about onsite or online training, mentoring and consulting solutions for HTML5, jQuery, .NET, SharePoint or Silverlight please visit &lt;a href="http://www.thewahlingroup.com/"&gt;http://www.thewahlingroup.com&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8029819" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/JSON/default.aspx">JSON</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/HTML5/default.aspx">HTML5</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/IE9/default.aspx">IE9</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/DevConnections/default.aspx">DevConnections</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Canvas/default.aspx">Canvas</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/WinRT/default.aspx">WinRT</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Windows+8/default.aspx">Windows 8</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/EF+Code+First/default.aspx">EF Code First</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Metro+Apps/default.aspx">Metro Apps</category></item><item><title>Video: HTML5 and JavaScript Tips</title><link>http://weblogs.asp.net/dwahlin/archive/2011/11/02/video-html5-and-javascript-tips.aspx</link><pubDate>Thu, 03 Nov 2011 04:31:02 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8029692</guid><dc:creator>dwahlin</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=8029692</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2011/11/02/video-html5-and-javascript-tips.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_13A4F1EE.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 20px 20px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" align="left" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_79D0BBBE.png" width="80" height="111" /&gt;&lt;/a&gt;I had the opportunity to present at the HTML5 Web Camp event in Phoenix, Arizona last month with &lt;a href="http://www.palermo4.com" target="_blank"&gt;Michael Palermo&lt;/a&gt; (one of my favorite speakers) and the recording of the event is now available online. Thanks to &lt;a href="http://scottcate.com/" target="_blank"&gt;Scott Cate&lt;/a&gt; and the &lt;a href="http://blog.eventday.com/" target="_blank"&gt;EventDay&lt;/a&gt; staff for taking time to record, index, and publish the event – they did an awesome job.&lt;/p&gt;  &lt;p&gt;I discussed using the HTML5 canvas along with JavaScript patterns to make your code more reusable and easier to maintain. Click the image below to watch the presentation.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.palermo4.com/page/Video-HTML5-Canvas-and-JavaScript-Tips.aspx" target="_blank"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_7D4D457F.png" width="678" height="432" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Several other people presented as well including my good buddies &lt;a href="http://www.rickgaribay.net/" target="_blank"&gt;Rick Garibay&lt;/a&gt;, &lt;a href="http://www.josephguadagno.net/" target="_blank"&gt;Joe Guadagno&lt;/a&gt;, and of course &lt;a href="http://www.palermo4.com" target="_blank"&gt;Michael Palermo&lt;/a&gt;. Here’s a complete list of all the videos from the event:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://www.palermo4.com/page/Video-Intro-to-HTML5.aspx" target="_blank"&gt;Intro to HTML5&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.palermo4.com/page/Video-Practical-HTML5.aspx" target="_blank"&gt;Practical HTML5&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.palermo4.com/page/Video-HTML5-and-CSS3.aspx" target="_blank"&gt;HTML5 &amp;amp; CSS3&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.palermo4.com/page/Video-Audio-Video-SVG.aspx" target="_blank"&gt;Audio, Video, SVG, Canvas&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.palermo4.com/page/Video-HTML5-Canvas-and-JavaScript-Tips.aspx" target="_blank"&gt;HTML5 JavaScript Tips&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.thewahlingroup.com/"&gt;&lt;img title="Logo" border="0" alt="Logo" src="http://weblogs.asp.net/blogs/dwahlin/Logo_702D5F60.jpg" width="240" height="57" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;For more information about onsite or online training, mentoring and consulting solutions for HTML5, jQuery, .NET, SharePoint or Silverlight please visit &lt;a href="http://www.thewahlingroup.com"&gt;http://www.thewahlingroup.com&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8029692" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/JSON/default.aspx">JSON</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/HTML5/default.aspx">HTML5</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Canvas/default.aspx">Canvas</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/CSS/default.aspx">CSS</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Design+Patterns/default.aspx">Design Patterns</category></item><item><title>Techniques, Strategies and Patterns for Structuring JavaScript Code</title><link>http://weblogs.asp.net/dwahlin/archive/2011/10/31/techniques-strategies-and-patterns-for-structuring-javascript-code.aspx</link><pubDate>Mon, 31 Oct 2011 21:26:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7891781</guid><dc:creator>dwahlin</dc:creator><slash:comments>26</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=7891781</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2011/10/31/techniques-strategies-and-patterns-for-structuring-javascript-code.aspx#comments</comments><description>&lt;p&gt;JavaScript has come a long way since the mid-90s when I first started working with it in Netscape 3 and Internet Explorer 3. Back in the day I thought JavaScript was a painful to use but over the years I’ve learned to love it and appreciate what it offers as a language.&amp;#160; JavaScript is quite flexible and can perform a wide variety of tasks on both the client-side and server-side. In fact, I used to prefer it to VBScript on the server-side when writing classic ASP applications and today we have server-side frameworks such as &lt;a href="http://www.nodejs.org/" target="_blank"&gt;Node.js&lt;/a&gt; that are JavaScript based. With the rise of HTML5 and new features such as the Canvas API and SVG JavaScript is more important than ever when building applications. As applications use more JavaScript it’s important that the code is structured in a way that’s easy work with and maintain.&lt;/p&gt;  &lt;p&gt;Although JavaScript isn’t designed with the concept of classes or object oriented programming in mind as with C# or Java, with a little work you can achieve similar results. In this series of posts I’ll discuss a few popular techniques/strategies/patterns (pick whichever term you prefer) for structuring JavaScript to encapsulate functionality much like classes do, hide private members, and provide a better overall re-use strategy and maintenance story in applications. The patterns that will be discussed in upcoming posts include:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://weblogs.asp.net/dwahlin/archive/2011/08/01/techniques-strategies-and-patterns-for-structuring-javascript-code-the-prototype-pattern.aspx"&gt;Prototype Pattern&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/dwahlin/archive/2011/08/02/techniques-strategies-and-patterns-for-structuring-javascript-code-revealing-module-pattern.aspx"&gt;Revealing Module Pattern&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/dwahlin/archive/2011/08/03/techniques-strategies-and-patterns-for-structuring-javascript-code-revealing-prototype-pattern.aspx"&gt;Revealing Prototype Pattern&lt;/a&gt; &lt;/li&gt; 
&lt;li&gt;&lt;a href="http://weblogs.asp.net/dwahlin/archive/2011/09/05/creating-multiple-javascript-objects-when-using-the-revealing-module-pattern.aspx"&gt;Creating Multiple JavaScript Objects when using the Revealing Module Pattern&lt;/a&gt;&lt;/li&gt;

&lt;/ul&gt;  &lt;p&gt;I’ll use a calculator example throughout the posts to demonstrate different techniques that can be used for structuring JavaScript code. I decided on a calculator since it provides a simple starting point that everyone understands without needing a detailed explanation. An example of the calculator interface is shown next. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_5FA0C39D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_3F1983EB.png" width="240" height="210" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;I use specific add, subtract, multiply, divide functions in the code that’ll be shown mainly because I tend to avoid eval() and I wanted to add enough functions to realistically demonstrate why taking the time to learn JavaScript code structuring techniques and patterns is worthwhile. In this first post in the series we’ll look at the technique most people use when writing JavaScript code, examine the role of closures, and discuss different ways to define variables. After that I’ll add additional posts covering the patterns mentioned earlier. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;Function Spaghetti Code&lt;/h2&gt;  &lt;p&gt;Most people (including myself) start out writing JavaScript code by adding function after function into a .js or HTML file. While there’s certainly nothing wrong with that approach since it gets the job done, it can quickly get out of control when working with a lot of code. When lumping functions into a file, finding code can be difficult, refactoring code is a huge chore (unless you have a nice tool like &lt;a href="http://www.jetbrains.com/resharper/" target="_blank"&gt;Resharper 6.0&lt;/a&gt;), variable scope can become an issue, and performing maintenance on the code can be a nightmare especially if you didn’t originally write it. The following code sample demonstrates using the function based approach to create a simple calculator that I threw together. It’s not perfect, but it gets the job done for the pattern samples that will be posted later.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;pre class="code"&gt;window.onload = &lt;span style="color: blue"&gt;function &lt;/span&gt;() {
    eqCtl = document.getElementById(&lt;span style="color: maroon"&gt;'eq'&lt;/span&gt;);
    currNumberCtl = document.getElementById(&lt;span style="color: maroon"&gt;'currNumber'&lt;/span&gt;);
};

&lt;span style="color: blue"&gt;var &lt;/span&gt;eqCtl,
    currNumberCtl,
    operator,
    operatorSet = &lt;span style="color: blue"&gt;false&lt;/span&gt;,
    equalsPressed = &lt;span style="color: blue"&gt;false&lt;/span&gt;,
    lastNumber = &lt;span style="color: blue"&gt;null&lt;/span&gt;;

&lt;span style="color: blue"&gt;function &lt;/span&gt;add(x,y) {
    &lt;span style="color: blue"&gt;return &lt;/span&gt;x + y;
}

&lt;span style="color: blue"&gt;function &lt;/span&gt;subtract(x, y) {
    &lt;span style="color: blue"&gt;return &lt;/span&gt;x - y;
}

&lt;span style="color: blue"&gt;function &lt;/span&gt;multiply(x, y) {
    &lt;span style="color: blue"&gt;return &lt;/span&gt;x * y;
}

&lt;span style="color: blue"&gt;function &lt;/span&gt;divide(x, y) {
    &lt;span style="color: blue"&gt;if &lt;/span&gt;(y == 0) {
        alert(&lt;span style="color: maroon"&gt;&amp;quot;Can't divide by 0&amp;quot;&lt;/span&gt;);
        &lt;span style="color: blue"&gt;return &lt;/span&gt;0;
    }
    &lt;span style="color: blue"&gt;return &lt;/span&gt;x / y;
}
     
&lt;span style="color: blue"&gt;function &lt;/span&gt;setVal(val) {
    currNumberCtl.innerHTML = val;
}
        
&lt;span style="color: blue"&gt;function &lt;/span&gt;setEquation(val) {
    eqCtl.innerHTML = val;
}
        
&lt;span style="color: blue"&gt;function &lt;/span&gt;clearNumbers() {
    lastNumber = &lt;span style="color: blue"&gt;null&lt;/span&gt;;
    equalsPressed = operatorSet = &lt;span style="color: blue"&gt;false&lt;/span&gt;;
    setVal(&lt;span style="color: maroon"&gt;'0'&lt;/span&gt;);
    setEquation(&lt;span style="color: maroon"&gt;''&lt;/span&gt;);
}

&lt;span style="color: blue"&gt;function &lt;/span&gt;setOperator(newOperator) {
    &lt;span style="color: blue"&gt;if &lt;/span&gt;(newOperator == &lt;span style="color: maroon"&gt;'='&lt;/span&gt;) {
        equalsPressed = &lt;span style="color: blue"&gt;true&lt;/span&gt;;
        calculate();
        setEquation(&lt;span style="color: maroon"&gt;''&lt;/span&gt;);
        &lt;span style="color: blue"&gt;return&lt;/span&gt;;
    }
            
    &lt;span style="color: #006400"&gt;//Handle case where = was pressed
    //followed by an operator (+, -, *, /)
    &lt;/span&gt;&lt;span style="color: blue"&gt;if &lt;/span&gt;(!equalsPressed) calculate();
    equalsPressed = &lt;span style="color: blue"&gt;false&lt;/span&gt;;
    operator = newOperator;
    operatorSet = &lt;span style="color: blue"&gt;true&lt;/span&gt;;
    lastNumber = parseFloat(currNumberCtl.innerHTML);
    &lt;span style="color: blue"&gt;var &lt;/span&gt;eqText = (eqCtl.innerHTML == &lt;span style="color: maroon"&gt;''&lt;/span&gt;) ? 
        lastNumber + &lt;span style="color: maroon"&gt;' ' &lt;/span&gt;+ operator + &lt;span style="color: maroon"&gt;' ' &lt;/span&gt;: 
        eqCtl.innerHTML + &lt;span style="color: maroon"&gt;' ' &lt;/span&gt;+ operator + &lt;span style="color: maroon"&gt;' '&lt;/span&gt;;
    setEquation(eqText);
}

&lt;span style="color: blue"&gt;function &lt;/span&gt;numberClick(e) {
    &lt;span style="color: blue"&gt;var &lt;/span&gt;button = (e.target) ? e.target : e.srcElement;
    &lt;span style="color: blue"&gt;if &lt;/span&gt;(operatorSet == &lt;span style="color: blue"&gt;true &lt;/span&gt;|| currNumberCtl.innerHTML == &lt;span style="color: maroon"&gt;'0'&lt;/span&gt;) {
        setVal(&lt;span style="color: maroon"&gt;''&lt;/span&gt;);
        operatorSet = &lt;span style="color: blue"&gt;false&lt;/span&gt;;            
    }
    setVal(currNumberCtl.innerHTML + button.innerHTML);
    setEquation(eqCtl.innerHTML + button.innerHTML);
}

&lt;span style="color: blue"&gt;function &lt;/span&gt;calculate() {
    &lt;span style="color: blue"&gt;if &lt;/span&gt;(!operator || lastNumber == &lt;span style="color: blue"&gt;null&lt;/span&gt;) &lt;span style="color: blue"&gt;return&lt;/span&gt;;
    &lt;span style="color: blue"&gt;var &lt;/span&gt;currNumber = parseFloat(currNumberCtl.innerHTML),
        newVal = 0;
    &lt;span style="color: #006400"&gt;//eval() would've made this a whole lot simpler
    //but didn't want to use it in favor of a more
    //&amp;quot;robust&amp;quot; set of methods to demo patterns
    &lt;/span&gt;&lt;span style="color: blue"&gt;switch &lt;/span&gt;(operator) {
        &lt;span style="color: blue"&gt;case &lt;/span&gt;&lt;span style="color: maroon"&gt;'+'&lt;/span&gt;:
            newVal = add(lastNumber, currNumber);
            &lt;span style="color: blue"&gt;break&lt;/span&gt;;
        &lt;span style="color: blue"&gt;case &lt;/span&gt;&lt;span style="color: maroon"&gt;'-'&lt;/span&gt;:
            newVal = subtract(lastNumber, currNumber);
            &lt;span style="color: blue"&gt;break&lt;/span&gt;;
        &lt;span style="color: blue"&gt;case &lt;/span&gt;&lt;span style="color: maroon"&gt;'*'&lt;/span&gt;:
            newVal = multiply(lastNumber, currNumber);
            &lt;span style="color: blue"&gt;break&lt;/span&gt;;
        &lt;span style="color: blue"&gt;case &lt;/span&gt;&lt;span style="color: maroon"&gt;'/'&lt;/span&gt;:
            newVal = divide(lastNumber, currNumber);
            &lt;span style="color: blue"&gt;break&lt;/span&gt;;
    }
    setVal(newVal);
    lastNumber = newVal;
}&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;Although I’m quite confident this code can be refactored in some manner within the functions (it was thrown together quickly for demonstration purposes), you can see it performs a few key calculator features such as handling arithmetic operations, detecting when operators are selected and performing calculations. Although everything shown in the code is standard JavaScript and works fine, as the number of functions grows things can quickly get out of hand. You can put the code in a file named calculator.js and then use it in as many pages as you’d like. However, if you come from an object oriented language you’d probably like to encapsulate the functionality into the equivalent of a “class”. Although classes aren’t supported directly in JavaScript, you can emulate the functionality using different types of patterns. &lt;/p&gt;

&lt;p&gt;Another problem with this type of code is that any variables defined outside of functions are placed in the global scope by default. The script shown above adds 6 variables to the global scope (the functions get added as well by the way). This means that they can more easily be stepped on or changed by anything in your script or another script that may be using the same variable names. It’d be nice to localize the global variables and limit their scope to avoid variable and scope conflicts. Fortunately that can be done using functions. However, if you define a variable in a function it goes away after the function returns right? That problem can be remedied by using closures which are an important part of the JavaScript patterns that I’ll cover in this series.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h2&gt;What are Closures?&lt;/h2&gt;

&lt;p&gt;The patterns that will be discussed in this series rely on a key concept in JavaScript called closures.&amp;#160; If you’re new to closures then I highly recommend reading the &lt;a href="http://blog.morrisjohns.com/javascript_closures_for_dummies.html" target="_blank"&gt;JavaScript Closures for Dummies&lt;/a&gt; article since it provides a nice overview along with several samples.&amp;#160; Closures are important because they allow stateful objects to be created without relying on variables defined in the &lt;a href="http://www.communitymx.com/content/article.cfm?cid=4E137" target="_blank"&gt;global scope&lt;/a&gt;. By using closures you can emulate features found in the class approach taken by object-oriented languages such as C# and Java. &lt;/p&gt;

&lt;p&gt;A closure is created when a function has variables that are bound to it in such a way that even after the function has returned, the variables stick around in memory. So what’s the magic that allows variables to be “bound” in such a way that they stick around even after a function returns? The answer is nested functions. When one function has a nested function inside of it, the nested function has access to the vars and parameters of the outer function and a “closure” is created behind the scenes. Douglas Crockford explains this with the &lt;a href="http://www.crockford.com/javascript/private.html" target="_blank"&gt;following quote&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;“What this means is that an inner function always has access to the vars and parameters of its outer function, even after the outer function has returned.”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To better understand closures examine the following code representing a standard JavaScript function without any closures: 
  &lt;br /&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;function &lt;/span&gt;myNonClosure() {
    &lt;span style="color: #006400"&gt;//variable will not be stored in a closure between calls
    //to the myNonClosure function
    &lt;/span&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;date = &lt;span style="color: blue"&gt;new &lt;/span&gt;Date();
    &lt;span style="color: blue"&gt;return &lt;/span&gt;date.getMilliseconds();
}&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;When the myNonClosure function is invoked the date variable will be assigned a new Date object. The function then returns the milliseconds. Calling the function multiple times will cause the date variable to be assigned a new value each time. This is of course the expected behavior. With a closure, a variable can be kept around even after a function returns a value. An example of a function named myClosure() that creates a closure is shown next: 

  &lt;br /&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: #006400"&gt;//closure example 
&lt;/span&gt;&lt;span style="color: blue"&gt;function &lt;/span&gt;myClosure() {
    &lt;span style="color: #006400"&gt;//date variable will be stored in a closure
    //due to the nested function referencing it
    &lt;/span&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;date = &lt;span style="color: blue"&gt;new &lt;/span&gt;Date();

    &lt;span style="color: #006400"&gt;//nested function &lt;/span&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;return function &lt;/span&gt;() {
        &lt;span style="color: blue"&gt;var &lt;/span&gt;otherDate = &lt;span style="color: blue"&gt;new &lt;/span&gt;Date();
        &lt;span style="color: blue"&gt;return &lt;/span&gt;&lt;span style="color: maroon"&gt;&amp;quot;Closure variable value for milliseconds: &amp;lt;span class='blue'&amp;gt;&amp;quot; &lt;/span&gt;+
                date.getMilliseconds() +
                &lt;span style="color: maroon"&gt;&amp;quot;&amp;lt;/span&amp;gt;&amp;lt;br&amp;gt;Non closure variable value for milliseconds: &amp;lt;span class='red'&amp;gt;&amp;quot; &lt;/span&gt;+
                otherDate.getMilliseconds() +
                &lt;span style="color: maroon"&gt;&amp;quot;&amp;lt;/span&amp;gt;&amp;quot;&lt;/span&gt;;
    };
}&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;Looking through the code you can see that a variable named date is assigned a Date object which is similar to the variable shown earlier. However, notice that myClosure returns a nested function which references the date variable. This creates a closure causing the date variable to be kept around even after a value has been returned from the function.&amp;#160; To see this in action the following code can be run: 

  &lt;br /&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;pre class="code"&gt;window.onload = &lt;span style="color: blue"&gt;function &lt;/span&gt;() {
    &lt;span style="color: #006400"&gt;//Using a closure
    &lt;/span&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;output = document.getElementById(&lt;span style="color: maroon"&gt;'Output'&lt;/span&gt;),
        closure = myClosure();
    output.innerHTML = closure();
    setTimeout(&lt;span style="color: blue"&gt;function&lt;/span&gt;() {
        output.innerHTML += &lt;span style="color: maroon"&gt;'&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;' &lt;/span&gt;+ closure();
    }, 1500);
};&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;The code first references the myClosure() function and stores it in a variable named “closure”. The nested function is then called with the closure() call (note that the name “closure” could be anything – I chose it simply to make its purpose obvious) which invokes the function and returns the current milliseconds. Next, a timeout is set to execute closure() again after 1.5 seconds have elapsed. The results of running the code are shown next.&amp;#160; They demonstrate how the date variable is kept around even across multiple calls to the myClosure function. This is an important feature of JavaScript that is leveraged by the different patterns that will be shown.&lt;/p&gt;

&lt;p&gt;
  &lt;br /&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_57107893.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_1263DE52.png" width="498" height="234" /&gt;&lt;/a&gt; 

  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;Here’s a final example of a closure for you to study. It follows one of the patterns that will be shown later in this series. Note that the myNestedFunc variable references a nested function that accesses the date variable. 
  &lt;br /&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;myClosure2 = &lt;span style="color: blue"&gt;function &lt;/span&gt;() {
    &lt;span style="color: blue"&gt;var &lt;/span&gt;date = &lt;span style="color: blue"&gt;new &lt;/span&gt;Date(),
        myNestedFunc = &lt;span style="color: blue"&gt;function &lt;/span&gt;() {
            &lt;span style="color: blue"&gt;return &lt;/span&gt;&lt;span style="color: maroon"&gt;&amp;quot;Closure for myNestedFunc: &amp;quot; &lt;/span&gt;+ date.getMilliseconds();
        };
    &lt;span style="color: blue"&gt;return &lt;/span&gt;{
        myNestedFunc: myNestedFunc
    };
} ();&lt;/pre&gt;

&lt;br /&gt;This code is called using the following syntax.&amp;#160; &lt;p&gt;
  &lt;br /&gt;output.innerHTML += &lt;span style="color: maroon"&gt;'&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;'&lt;/span&gt;+ myClosure2.myNestedFunc(); 

  &lt;br /&gt;

  &lt;br /&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;h2&gt;Defining Variables&lt;/h2&gt;

&lt;p&gt;Defining variables in JavaScript is one of the more simple aspects of the language. However, there are a few different ways to do it. For example, the following code is completely valid and what most people getting started with JavaScript do:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;eqCtl;
&lt;span style="color: blue"&gt;var &lt;/span&gt;currNumberCtl;
&lt;span style="color: blue"&gt;var &lt;/span&gt;operator;
&lt;span style="color: blue"&gt;var &lt;/span&gt;operatorSet = &lt;span style="color: blue"&gt;false&lt;/span&gt;;
&lt;span style="color: blue"&gt;var &lt;/span&gt;equalsPressed = &lt;span style="color: blue"&gt;false&lt;/span&gt;;
&lt;span style="color: blue"&gt;var &lt;/span&gt;lastNumber = &lt;span style="color: blue"&gt;null&lt;/span&gt;;&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;Although this code works fine, tools such as &lt;a href="http://jslint4vs2010.codeplex.com/" target="_blank"&gt;JSLint for Visual Studio&lt;/a&gt; will let you know to define the variables differently. In the posts that follow you’ll see code similar to the following when defining variables.&amp;#160; It only uses the JavaScript var keyword once and then separates variables with a comma. The code ultimately does the same thing as the code above but it reduces the size of the script and is more readable once you get used to it. Here’s an example of defining variables that keeps JSLint and other tools happier when they inspect your code:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;eqCtl,
    currNumberCtl,
    operator,
    operatorSet = &lt;span style="color: blue"&gt;false&lt;/span&gt;,
    equalsPressed = &lt;span style="color: blue"&gt;false&lt;/span&gt;,
    lastNumber = &lt;span style="color: blue"&gt;null&lt;/span&gt;;&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;In the next post I’ll discuss the Prototype Pattern and how you can use it to convert function spaghetti code into a more structured object. &lt;/p&gt;

&lt;p&gt;Demos of all the patterns covered in this series can be downloaded below.&lt;/p&gt;

&lt;h2&gt;&lt;a href="http://dl.dropbox.com/u/6037348/HTML5AndJavaScript/StructuringJavaScript.zip"&gt;Download Code&lt;/a&gt;&lt;/h2&gt;
&lt;br /&gt;
&lt;p&gt;Thanks to &lt;a href="http://www.johnpapa.net" target="_blank"&gt;John Papa&lt;/a&gt; for taking the time to review the code and offer suggestions and feedback.&lt;/p&gt;
&lt;br /&gt;&lt;br /&gt;

&lt;h2&gt;Pluralsight Course - Structuring JavaScript Code in HTML5 Applications&lt;/h2&gt;

If you're interested in additional information about structuring JavaScript code check out my &lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=structuring-javascript"&gt;Pluralsight course&lt;/a&gt;. Here's a sample from the course covering closures.
&lt;br /&gt;&lt;br /&gt;
&lt;strong&gt;Demo - Working with Closures in JavaScript&lt;/strong&gt;&lt;/p&gt;  &lt;br /&gt;&lt;object style="height:400px; width:512px"&gt;    &lt;param name="movie" value="http://www.youtube.com/v/t1B5TJQAKjM?version=3&amp;amp;feature=player_profilepage&amp;amp;hd=1"&gt;    &lt;param name="allowFullScreen" value="true"&gt;    &lt;param name="allowScriptAccess" value="always"&gt;    &lt;embed src="http://www.youtube.com/v/t1B5TJQAKjM?version=3&amp;amp;feature=player_profilepage&amp;amp;hd=1" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="512" height="400"&gt; &lt;/object&gt;
&lt;br /&gt;&lt;br /&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7891781" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/HTML5/default.aspx">HTML5</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Design+Patterns/default.aspx">Design Patterns</category></item><item><title>The Tablet Show  -  “Resist the Drama”</title><link>http://weblogs.asp.net/dwahlin/archive/2011/10/26/the-tablet-show-resist-the-drama.aspx</link><pubDate>Thu, 27 Oct 2011 02:09:53 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8014238</guid><dc:creator>dwahlin</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=8014238</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2011/10/26/the-tablet-show-resist-the-drama.aspx#comments</comments><description>&lt;p&gt;I had an opportunity to talk with Carl Franklin and Richard Campbell (the &lt;a href="http://dotnetrocks.com/" target="_blank"&gt;.NET Rocks guys&lt;/a&gt;) on their new show called &lt;a href="http://www.thetabletshow.com/default.aspx?showNum=2" target="_blank"&gt;The Tablet Show&lt;/a&gt;. It’s always fun talking with them since there’s never a boring moment or lull in the conversation. In this episode we talk about the new WinRT framework used to build Metro apps in Windows 8, the future of Silverlight, the drama some developers seem to love, and a bunch of other topics related to development including why Microsoft is moving toward the Start Screen that you see in Windows 8. Give the show a listen by clicking the image below.    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.thetabletshow.com/default.aspx?showNum=2" target="_blank"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_388C226F.png" width="637" height="600" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8014238" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/WPF/default.aspx">WPF</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/XAML/default.aspx">XAML</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/WinRT/default.aspx">WinRT</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Windows+8/default.aspx">Windows 8</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Metro+Apps/default.aspx">Metro Apps</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Tablets/default.aspx">Tablets</category></item></channel></rss>

