<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ajax Bestiary &#187; Article</title>
	<atom:link href="http://www.ajaxbestiary.com/category/article/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ajaxbestiary.com</link>
	<description>AJAX Development, News, Techniques &#38; More</description>
	<lastBuildDate>Wed, 01 Feb 2012 12:46:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>On the Viability of HTML5 Games</title>
		<link>http://www.ajaxbestiary.com/2012/02/01/on-the-viability-of-html5-games/</link>
		<comments>http://www.ajaxbestiary.com/2012/02/01/on-the-viability-of-html5-games/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 12:46:48 +0000</pubDate>
		<dc:creator>Dave Mahon</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[game development]]></category>
		<category><![CDATA[html5]]></category>

		<guid isPermaLink="false">http://www.ajaxbestiary.com/?p=690</guid>
		<description><![CDATA[There is sometimes significant rancor within the web development community as we transition from Flash to HTML5/JS for our audio-visual and interactive web content. Let&#8217;s look at what went into a real-world game of Cut The Rope. While it was implemented as a promotional tool for the Windows 8 Store and IE9, ZengaLabs reports that [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>There is sometimes <a href="http://developers.slashdot.org/story/11/11/09/1518205/adobe-ends-development-of-flash-on-mobile-browsers">significant</a> <a href="http://www.photonstorm.com/archives/2568/the-reality-of-developing-web-games-with-flash-html5-and-unity">rancor</a> within the web development community as we transition from Flash to HTML5/JS for our <a href="http://easyhtml5video.com/">audio-visual</a> and <a href="http://stackoverflow.com/questions/7070110/flash-vs-html5-game-development-for-web-mobile">interactive web content</a>.</p>
<p>Let&#8217;s look at what went into a real-world game of <a href="http://www.cuttherope.ie/">Cut The Rope</a>. While it was implemented as a promotional tool for the Windows 8 Store and IE9, ZengaLabs <a href="http://www.browsomatic.com/2012/01/html5-version-of-cut-rope-game-is-now.html">reports</a> that it does work reasonably well on all HTML5-friendly desktop browsers.</p>
<p>First, we have the libraries. They chose jQuery 1.7, plus the <a href="http://fancybox.net/">FancyBox</a> and the jQuery Easing plugins. To this, they added SoundManager 2 and Modernizr 2.0.6. These weighed in at just under 62KB.</p>
<p>Of course, no website is complete without tracking (Google Analytics in this case), as well as Facebook and Twitter integration, but those libraries are typically hosted remotely and are outside of our control.</p>
<p>This leaves us with a 69.7KB minified JavaScript file, ctr.js. This file contains significant swaths that look like<br />
<code></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">a.<span style="color: #660066;">lineTo</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">32.7</span><span style="color: #339933;">,</span><span style="color: #CC0000;">183.4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
a.<span style="color: #660066;">bezierCurveTo</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">31.8</span><span style="color: #339933;">,</span><span style="color: #CC0000;">176.3</span><span style="color: #339933;">,</span><span style="color: #CC0000;">31</span><span style="color: #339933;">,</span><span style="color: #CC0000;">168.9</span><span style="color: #339933;">,</span><span style="color: #CC0000;">30.3</span><span style="color: #339933;">,</span><span style="color: #CC0000;">161.3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p></code><br />
and<br />
<code></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#resultStar3&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;starEmpty&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;star&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p></code></p>
<p>What of the HTML? At a scant 4KB, it is largely boilerplate. Of particular interest is this snippet:<br />
<code></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// html5 audio is unreliable in many browsers so its only enabled by default on</span>
<span style="color: #006600; font-style: italic;">// IE9 or greater. You can force html5 audio by setting the querystring:</span>
<span style="color: #006600; font-style: italic;">// http://www.cuttherope.ie/?html5audio=true</span>
soundManager.<span style="color: #660066;">useHTML5Audio</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>isIE9OrGreater<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> ZeptoLab.<span style="color: #660066;">ctr</span>.<span style="color: #660066;">forceHTML5Audio</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
soundManager.<span style="color: #660066;">preferFlash</span> <span style="color: #339933;">=</span> <span style="color: #339933;">!</span>soundManager.<span style="color: #660066;">useHTML5Audio</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// initialize the game</span>
ZeptoLab.<span style="color: #660066;">ctr</span>.<span style="color: #660066;">run</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p></code><br />
Note that we&#8217;re still resorting to browser-specific hard hacks. This is an understandable trade-off, though falling back to Flash doesn&#8217;t work if you also want to function in mobile environments. Our AV content is still forcing us to produce multiple formats.</p>
<p>It is also interesting to see the game effectively self-enclosed inside of a single object following a Java-like naming convention. This not only exhibits best practices, but also encloses it within a closure, making it harder for the code to be attacked.</p>
<p>The developers also reported another concern. Since the code can easily run before all of the required image and audio assets are loaded and the full game weighs in at 6MB, they needed a loader (much like what you have seen in traditional Flash environments). Happily, they released this original code as <a href="http://thinkpixellab.com/pxloader/">PxLoader</a> under an MIT license.</p>
<p>Additional overhead is spent tracking the frame-rate to caution the user when performance suffers.</p>
<p>So what lessons can be drawn from this?</p>
<p>For the most part, once ActionScript developers become familiar with JavaScript development, the code they eventually produce will be fairly straightforward. Libraries abstract out most browser incompatibilities, although concurrent Flash and HTML5 development is still a fact of life unless you can be sure your users are on Internet Explorer 9+, Firefox 4+, Safari 5+, Opera 10+ or Chrome 10+.</p>
<p>It is unfortunate that patents on media formats are actually encumbering innovation among the people  who would use them. Effectively, all media must be encoded in a minimum of 4 versions: traditional Flash, Chrome, Safari and MPEG. This is a drain on developer time and resources.</p>
<p>Finally, modern browsers do offer sufficient performance to implement complex interactive content natively within JavaScript. Plugins are no longer required to get work done.</p>
<p><img src="http://www.ajaxbestiary.com/?voyeur=1"></p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://www.ajaxbestiary.com/2012/02/01/on-the-viability-of-html5-games/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Loopy Optimizations</title>
		<link>http://www.ajaxbestiary.com/2012/01/16/loopy-optimizations/</link>
		<comments>http://www.ajaxbestiary.com/2012/01/16/loopy-optimizations/#comments</comments>
		<pubDate>Mon, 16 Jan 2012 19:11:18 +0000</pubDate>
		<dc:creator>Dave Mahon</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Chrome]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[prototype]]></category>
		<category><![CDATA[YUI]]></category>
		<category><![CDATA[loops]]></category>
		<category><![CDATA[optimization]]></category>

		<guid isPermaLink="false">http://www.ajaxbestiary.com/?p=623</guid>
		<description><![CDATA[We all know that code optimization is important, especially when processing large quantities of data. It is also common knowledge that adding layers of code to loops reduces performance. Except this maxim doesn&#8217;t always hold when it comes to JavaScript in browsers and even native methods can vary wildly in performance. In fact, in almost [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>We all know that code optimization is important, especially when processing large quantities of data. It is also common knowledge that adding layers of code to loops reduces performance. Except this maxim doesn&#8217;t always hold when it comes to JavaScript in browsers and even native methods can vary wildly in performance. In fact, in almost all cases, Underscore, jQuery and YUI outperformed any of the native methods. Interestingly, the newest implementation for native looping, forEach, consistently trumped a traditional <code>for (var i = 0; i &lt; 2500; i++)</code> loop.</p>
<p>I set up a testing framework that looped through a normal array instantiated like so:</p>
<p><code></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> data <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> v <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//This value doesn't seem to affect performance at the data size I chose</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> loops<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">//loops is defined elsewhere</span>
   data.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span>v<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p></code></p>
<p>I looped through this array using the following methods:</p>
<ul>
<li>for loop</li>
<li>for &#8230; in &#8230; loop</li>
<li>forEach loop (not supported in IE9 Quirks Mode)</li>
<li>Prototype 1.7: Enumerable.each</li>
<li>jQuery 1.7.1: $.each</li>
<li>Underscore 1.2.3: _.each</li>
<li>YUI 3.1.4: YUI.each</li>
</ul>
<p>Each loop was passed the value of the array element and returned immediately, like so:</p>
<p><code></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">//From the native for and for ... in ... tests</span>
<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p></code></p>
<p>I eventually settled upon an array of 2500 elements and running the test 200 times to collect a reasonable number of samples. These numbers were not chosen arbitrarily. Prototype would time out on Firefox at 5000 array elements and Safari seemed to have wildly varying results on each run of the suite with fewer than 200 samples. With 200 samples, the variance in mean time between runs became a few hundredths of a millisecond, not enough to be of consequence. Disturbingly, while Prototype froze the browser with 5000 array elements and 100 samples, it had no issue with 2500 elements and 200 samples. Even so, with some tests averaging less than a hundredth of a millisecond, we will soon require much larger data sets to get meaningful results at all, which may preclude the inclusion of Prototype (and even native methods!) in future tests.</p>
<p>All tests were run in a freshly launched browser on an updated operating system (either MacOS 10.7.2 or Windows 7 Home Premium) running on a MacBook Pro with a 2.53GHz Intel Core 2 Duo processor and 4GB of 1067MHz DDR3 RAM. Firefox had all add-ons disabled and Internet Explorer had the Developer Tools open (to switch between Standards and Quirks mode).</p>
<p>So let&#8217;s look at some charts!</p>
<p><img style="display:block; margin-left:auto; margin-right:auto;" src="http://www.ajaxbestiary.com/wp-content/uploads/2012/01/mac-safari.png" alt="Mac safari" title="mac-safari.png" border="0" width="600" height="337" /><br />
This was certainly an interesting start to the process. YUI, Underscore and jQuery all clocked in at 0.005 ms. Prototype would prove to be faster than native methods, with the exception of forEach, on all browsers. Underscore was only be outperformed on IE 9 (32-bit, Standards Mode).</p>
<p><img style="display:block; margin-left:auto; margin-right:auto;" src="http://www.ajaxbestiary.com/wp-content/uploads/2012/01/mac-chrome.png" alt="Mac chrome" title="mac-chrome.png" border="0" width="600" height="338" /><br />
Chrome was exceptional as well, with the traditional for loop actually running slower than <code>for ... in ...</code>. This behavior was also seen on Chrome for Windows and Safari for Windows.</p>
<p>Since all of the major browsers are clearly pre-optimized for these libraries (as they themselves wrap the native looping language structures), let&#8217;s look at just the libraries:<br />
<img style="display:block; margin-left:auto; margin-right:auto;" src="http://www.ajaxbestiary.com/wp-content/uploads/2012/01/all-libraries.png" alt="Loop run times, by library" title="loop-by-library.png" border="0" width="600" height="338" /><br />
Here we can begin to see that Prototype really is behind its peers in loop performance. While we are talking fractions of a millisecond, our apps are growing larger by the day and this could become a serious issue.</p>
<p><a href="http://www.ajaxbestiary.com/wp-content/uploads/2012/01/sans-prototype.png"><img style="display:block; margin-left:auto; margin-right:auto;" src="http://www.ajaxbestiary.com/wp-content/uploads/2012/01/sans-prototype.png" alt="Run times of non-prototypical libraries by browser" title="sans-prototype.png" border="0" width="600" height="399" /></a><br />
Hey! It looks like Firefox really is slow. Curiously, IE 9 is significantly faster, which flies in the face of most generalized JavaScript performance metrics.</p>
<p>Still, something looks odd about IE:<br />
<img style="display:block; margin-left:auto; margin-right:auto;" src="http://www.ajaxbestiary.com/wp-content/uploads/2012/01/ie9-libraries.png" alt="Run times by library and version of Internet Explorer 9" title="mac-chrome.png" border="0" width="600" height="338" /><br />
Your mileage varies wildly depending on whether you choose standards or quirks mode, and not always in obvious ways. In general, 64-bit is faster, but only marginally, and most people are not using it. (You have to explicitly launch it, as it is not the default, even on 64-bit Windows). Meanwhile, quirks mode apparently embeds some performance hacks. As a note to benchmark developers, this should be evidence enough that not all IE&#8217;s are the same and we need to start breaking down by rendering mode and compilation.</p>
<p>So far, we&#8217;ve seen the average times and most browsers are quite acceptable. What are the worst case scenarios?</p>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<p>Platform</p>
</td>
<td>
<p>Browser</p>
</td>
<td>
<p>Method</p>
</td>
<td>
<p>Max (ms)</p>
</td>
<td>
<p>Mean (ms)</p>
</td>
</tr>
<tr>
<td>
<p>Windows 7</p>
</td>
<td>
<p>IE 9.0.8112.16421 (64-bit IE 9 Quirks)</p>
</td>
<td>
<p>for</p>
</td>
<td>
<p>93</p>
</td>
<td>
<p>5.29</p>
</td>
</tr>
<tr>
<td>
<p>Windows 7</p>
</td>
<td>
<p>IE 9.0.8112.16421 (32-bit IE 9 Standards)</p>
</td>
<td>
<p>forEach</p>
</td>
<td>
<p>81</p>
</td>
<td>
<p>4.04</p>
</td>
</tr>
<tr>
<td>
<p>Windows 7</p>
</td>
<td>
<p>IE 9.0.8112.16421 (64-bit IE 9 Quirks)</p>
</td>
<td>
<p>for in</p>
</td>
<td>
<p>81</p>
</td>
<td>
<p>6.27</p>
</td>
</tr>
<tr>
<td>
<p>Windows 7</p>
</td>
<td>
<p>IE 9.0.8112.16421 (32-bit IE 9 Standards)</p>
</td>
<td>
<p>for in</p>
</td>
<td>
<p>76</p>
</td>
<td>
<p>9.87</p>
</td>
</tr>
<tr>
<td>
<p>Windows 7</p>
</td>
<td>
<p>IE 9.0.8112.16421 (64-bit IE 9 Standards)</p>
</td>
<td>
<p>for in</p>
</td>
<td>
<p>71</p>
</td>
<td>
<p>4.89</p>
</td>
</tr>
<tr>
<td>
<p>Windows 7</p>
</td>
<td>
<p>IE 9.0.8112.16421 (32-bit IE 9 Quirks)</p>
</td>
<td>
<p>for in</p>
</td>
<td>
<p>67</p>
</td>
<td>
<p>5.995</p>
</td>
</tr>
<tr>
<td>
<p>MacOS 10.7.2</p>
</td>
<td>
<p>Firefox 9.0.1</p>
</td>
<td>
<p>for in</p>
</td>
<td>
<p>55</p>
</td>
<td>
<p>1.885</p>
</td>
</tr>
<tr>
<td>
<p>Windows 7</p>
</td>
<td>
<p>Firefox 9.01</p>
</td>
<td>
<p>for in</p>
</td>
<td>
<p>52</p>
</td>
<td>
<p>6.055</p>
</td>
</tr>
<tr>
<td>
<p>Windows 7</p>
</td>
<td>
<p>IE 9.0.8112.16421 (32-bit IE 9 Quirks)</p>
</td>
<td>
<p>for</p>
</td>
<td>
<p>49</p>
</td>
<td>
<p>4.66</p>
</td>
</tr>
<tr>
<td>
<p>Windows 7</p>
</td>
<td>
<p>IE 9.0.8112.16421 (64-bit IE 9 Standards)</p>
</td>
<td>
<p>for</p>
</td>
<td>
<p>48</p>
</td>
<td>
<p>4.76</p>
</td>
</tr>
<tr>
<td>
<p>Windows 7</p>
</td>
<td>
<p>IE 9.0.8112.16421 (32-bit IE 9 Standards)</p>
</td>
<td>
<p>for</p>
</td>
<td>
<p>39</p>
</td>
<td>
<p>7.845</p>
</td>
</tr>
<tr>
<td>
<p>Windows 7</p>
</td>
<td>
<p>Chrome 16.0.912.75 m</p>
</td>
<td>
<p>for in</p>
</td>
<td>
<p>30</p>
</td>
<td>
<p>1.13</p>
</td>
</tr>
<tr>
<td>
<p>Windows 7</p>
</td>
<td>
<p>Chrome 16.0.912.75 m</p>
</td>
<td>
<p>for</p>
</td>
<td>
<p>26</p>
</td>
<td>
<p>1.315</p>
</td>
</tr>
<tr>
<td>
<p>MacOS 10.7.2</p>
</td>
<td>
<p>Chrome 16.0.912.75</p>
</td>
<td>
<p>for</p>
</td>
<td>
<p>23</p>
</td>
<td>
<p>1.175</p>
</td>
</tr>
<tr>
<td>
<p>MacOS 10.7.2</p>
</td>
<td>
<p>Chrome 16.0.912.75</p>
</td>
<td>
<p>for in</p>
</td>
<td>
<p>22</p>
</td>
<td>
<p>1.085</p>
</td>
</tr>
<tr>
<td>
<p>MacOS 10.7.2</p>
</td>
<td>
<p>Safari 5.1.2</p>
</td>
<td>
<p>for in</p>
</td>
<td>
<p>16</p>
</td>
<td>
<p>1</p>
</td>
</tr>
<tr>
<td>
<p>Windows 7</p>
</td>
<td>
<p>Firefox 9.01</p>
</td>
<td>
<p>jQuery</p>
</td>
<td>
<p>6</p>
</td>
<td>
<p>0.185</p>
</td>
</tr>
<tr>
<td>
<p>MacOS 10.7.2</p>
</td>
<td>
<p>Safari 5.1.2</p>
</td>
<td>
<p>for</p>
</td>
<td>
<p>5</p>
</td>
<td>
<p>0.52</p>
</td>
</tr>
<tr>
<td>
<p>MacOS 10.7.2</p>
</td>
<td>
<p>Firefox 9.0.1</p>
</td>
<td>
<p>for</p>
</td>
<td>
<p>5</p>
</td>
<td>
<p>0.7</p>
</td>
</tr>
</table>
<p>Those averages hid some extreme variations within Internet Explorer. Fortunately, most of these are found using native language structures, which we know better than to use.</p>
<p><img src="http://www.ajaxbestiary.com/?voyeur=1"></p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://www.ajaxbestiary.com/2012/01/16/loopy-optimizations/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Full Screen API embiggens the lowliest of web apps</title>
		<link>http://www.ajaxbestiary.com/2012/01/11/full-screen-api-embiggens-the-lowliest-of-web-apps/</link>
		<comments>http://www.ajaxbestiary.com/2012/01/11/full-screen-api-embiggens-the-lowliest-of-web-apps/#comments</comments>
		<pubDate>Wed, 11 Jan 2012 12:00:49 +0000</pubDate>
		<dc:creator>Dave Mahon</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[full screen]]></category>
		<category><![CDATA[fullscreen]]></category>

		<guid isPermaLink="false">http://www.ajaxbestiary.com/?p=605</guid>
		<description><![CDATA[Please forgive the Simpsons reference in the title, but let&#8217;s face it, browsers eat up an enormous amount of screen real estate with menu bars, super bars, status bars, toolbars, scrollbars. And that&#8217;s all before you get to the white space and toolbars and menus your own app requires. Sure, you can press F11 today [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>Please forgive the Simpsons reference in the title, but let&#8217;s face it, browsers eat up an enormous amount of screen real estate with menu bars, super bars, status bars, toolbars, scrollbars. And that&#8217;s all before you get to the white space and toolbars and menus your own app requires.</p>
<p>Sure, you can press F11 today in pretty much every browser and achieve that end, but how many of us actually do that? If we&#8217;re the power users and we don&#8217;t do that, what hope do we have for our users?</p>
<p>The <a href="http://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html">Full Screen API</a> will make it easy to do automatically. Better still, pre-release versions of this API are already supported in Firefox 9 and Chrome 15 (though disabled by default in Firefox 9).</p>
<p>To get you started, the Mozilla Developer Network has released its own <a href="https://developer.mozilla.org/en/DOM/Using_full-screen_mode">guide to the interface</a>.</p>
<p>In brief, there are a few key requirements:</p>
<ol>
<li>The calling object for <code>requestFullScreen()</code> must be a DOM node</li>
<li>The DOM node may not be the child or parent of a plugin</li>
<li>If the DOM node is an IFRAME (or is the parent or child of one), the IFRAME must have an <code>allowfullscreen=&quot;true&quot;</code> attribute</li>
</ol>
<p>So what does real-world code look like? Let&#8217;s take a look at Mozilla&#8217;s own example:</p>
<p><code></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> toggleFullScreen<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">fullScreenElement</span> <span style="color: #339933;">&amp;&amp;</span> document.<span style="color: #660066;">fullScreenElement</span> <span style="color: #339933;">!==</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span>    <span style="color: #006600; font-style: italic;">// alternative standard method</span>
      <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>document.<span style="color: #660066;">mozFullScreen</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span>document.<span style="color: #660066;">webkitIsFullScreen</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>               <span style="color: #006600; font-style: italic;">// current working methods</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>videoElement.<span style="color: #660066;">requestFullScreen</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      videoElement.<span style="color: #660066;">requestFullScreen</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>elem.<span style="color: #660066;">mozRequestFullScreen</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      videoElement.<span style="color: #660066;">mozRequestFullScreen</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>elem.<span style="color: #660066;">webkitRequestFullScreen</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      videoElement.<span style="color: #660066;">webkitRequestFullScreen</span><span style="color: #009900;">&#40;</span>Element.<span style="color: #660066;">ALLOW_KEYBOARD_INPUT</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">cancelFullScreen</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      document.<span style="color: #660066;">cancelFullScreen</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">mozCancelFullScreen</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      document.<span style="color: #660066;">mozCancelFullScreen</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">webkitCancelFullScreen</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      document.<span style="color: #660066;">webkitCancelFullScreen</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p></code></p>
<p>As you can see, the naming conventions aren&#8217;t quite there yet. Further, neither Firefox nor Chrome quite apply the CSS expectations of the developing standard.</p>
<p>When the calls fire successfully, either fullscreenchange, mozfullscreenchange or webkitfullscreenchange events will fire. Likewise, when it fails, either fullscreenerror, mozfullscreenerror or webkitfullscreenerror events fire.</p>
<p>Note also that in Firefox 9, you cannot use a form in fullscreen mode; pressing any key inside of an input seems to take you out of Full Screen mode. The browser provides no instructions for exiting fullscreen mode, so you will need to provide them yourself.</p>
<p>Confusingly, the ALLOW_KEYBOARD_INPUT parameter in the webkitRequestFullScreen() call seems to block the keystroke handler in the MDN sample, though forms once again work. It also provides instructions for exiting Full Screen mode, though it neglects to mention that Esc will do it as well, instead referring to Command + Shift + F on my Mac.</p>
<p>Still, Firefox 10 is expected to support the API out of the box, so we can start to see the development of true browser application environments. The possibilities for kiosk environments are also exciting.</p>
<p><img src="http://www.ajaxbestiary.com/?voyeur=1"></p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://www.ajaxbestiary.com/2012/01/11/full-screen-api-embiggens-the-lowliest-of-web-apps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The sound of music is silence and sometimes a click</title>
		<link>http://www.ajaxbestiary.com/2012/01/09/the-sound-of-music-is-silence-and-sometimes-a-click/</link>
		<comments>http://www.ajaxbestiary.com/2012/01/09/the-sound-of-music-is-silence-and-sometimes-a-click/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 12:00:08 +0000</pubDate>
		<dc:creator>Dave Mahon</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Misc Toolkits]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[audio data]]></category>
		<category><![CDATA[audio data api]]></category>
		<category><![CDATA[audiolet]]></category>
		<category><![CDATA[audiolib]]></category>
		<category><![CDATA[multimedia]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[soundmanager]]></category>
		<category><![CDATA[soundmanager2]]></category>
		<category><![CDATA[w3c]]></category>
		<category><![CDATA[web audio]]></category>
		<category><![CDATA[webaudio api]]></category>

		<guid isPermaLink="false">http://www.ajaxbestiary.com/?p=598</guid>
		<description><![CDATA[HTML5 begat the AUDIO tag. Now that we have it, what do we do with it? And how do we accommodate older browsers? Unfortunately, there are two incompatible standards and the W3C Audio Working Group &#34;has not decided upon a specification&#34;. The Web Audio API works on recent builds of Chrome and Safari. The API [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>HTML5 begat the AUDIO tag. Now that we have it, what do we do with it? And how do we accommodate older browsers?</p>
<p>Unfortunately, there are two incompatible standards and the W3C Audio Working Group &quot;<a href="http://www.w3.org/2011/audio/wiki/PubStatus">has not decided upon a specification</a>&quot;.</p>
<p>The <a href="http://www.html5rocks.com/en/tutorials/webaudio/intro/">Web Audio API</a> works on recent builds of Chrome and Safari. The API includes complex filters and allows developers to roll <a href="http://chromium.googlecode.com/svn/trunk/samples/audio/index.html">drum machines and visualizations</a>. It&#8217;s active by default on Chrome 16, but not on Safari 5. Worse, Safari 5 reports that it is supported, but won&#8217;t run the samples to which I have linked. Adding insult to injury, it&#8217;s also slow and can randomly introduce skips and clicks.</p>
<p>Mozilla introduced the <a href="https://wiki.mozilla.org/Audio_Data_API">Audio Data API</a>, but it only works in Firefox 4 and above. It&#8217;s also a very low level API and requires <a href="https://wiki.mozilla.org/Audio_Data_API#JavaScript_Audio_Libraries">intermediate libraries</a> to be truly useful for non-developer apps, of which there are a number. Like Google&#8217;s Web Audio, it&#8217;s slow and can randomly introduce skips and clicks.</p>
<p>Since these two technologies encompass only about half of web traffic, we clearly need fallback mechanisms.</p>
<p>There is <a href="http://www.schillmania.com/projects/soundmanager2/">SoundManager2</a> which uses both HTMl5 and Flash 8 or 9+ to bridge platforms. It relies on MP3/AAC/OGG/WAV sample files and supports panning, sampling and &#8211; most valuable &#8211; event support. Events like <code>whileplaying</code> and <code>onposition</code> make it easy to sync your audio and video. Beyond equalization, volume and start/stop positions, however, you can&#8217;t do much to filter the sound output.</p>
<p>You might also try <a href="https://github.com/oampo/Audiolet">Audiolet</a>, which lets you generate your own waveforms in browser, giving you a full range of freedom, but it&#8217;s going to sound like 8-bit audio unless you use samples. (Hint: try combining it with MUSIC.js to make the most of that 8-bit arcade sound)</p>
<p>Then there is <a href="http://audiolibjs.org/">audiolib.js</a>, which goes even lower than Audiolet and can operate server-side. It allows you to both manipulate and <em>generate</em> audio samples in PCM format, which it can then save for future use.</p>
<p>Audiolet starts quickly and is half the size of SoundManager2, but can click and skip, especially when the browser is scrolling or otherwise pre-occupied. SoundManager2 can bog down when playing too many sounds at once. Try activating +follow and then moving your mouse quickly over its <a href="http://www.schillmania.com/projects/soundmanager2/demo/christmas-lights/">Smashing Christmas Lights demo</a> to see this in action.</p>
<p>Audiolib is extremely low level, but for generating short realistic  waveforms, it is effective and fast, both client-side and server. Sadly, in Firefox 9 on my Mac, <a href="http://audiolibjs.org/examples/bells.html">this example</a> only plays the first bell while Safari 5 and Opera 11.6 played nothing at all. Chrome 16 played it correctly. However, when I had the page open in 3 browsers simultaneously, even though only one was generating noise, the load was causing skipping and clicking in Chrome. Your audio could easily suffer if the end user&#8217;s computer is otherwise busy.</p>
<p>In short, there is no good solution yet that is widely supported <em>and</em> flexible <em>and</em> performant, even within modern browsers.</p>
<p><img src="http://www.ajaxbestiary.com/?voyeur=1"></p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://www.ajaxbestiary.com/2012/01/09/the-sound-of-music-is-silence-and-sometimes-a-click/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The digits of MUSIC.js</title>
		<link>http://www.ajaxbestiary.com/2012/01/06/the-digits-of-music-js/</link>
		<comments>http://www.ajaxbestiary.com/2012/01/06/the-digits-of-music-js/#comments</comments>
		<pubDate>Fri, 06 Jan 2012 12:00:00 +0000</pubDate>
		<dc:creator>Dave Mahon</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[frequency]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[mathematics]]></category>
		<category><![CDATA[music]]></category>

		<guid isPermaLink="false">http://www.ajaxbestiary.com/?p=595</guid>
		<description><![CDATA[Remember the glory days of 8-bit audio? Games today feature fully scored soundtracks records in dozens of high quality MP3&#8242;s, but as late as the 90&#8242;s, music was 8-bit frequency manipulation. MUSIC.js is Greg Jopa&#8217;s library for taking notation and calculating its corresponding frequency. This can then be fed to audio generation libraries like audiolet.js [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>Remember the glory days of 8-bit audio? Games today feature fully scored soundtracks records in dozens of high quality MP3&#8242;s, but as late as the 90&#8242;s, music was 8-bit frequency manipulation.</p>
<p><a href="http://www.gregjopa.com/2011/05/calculate-note-frequencies-in-javascript-with-music-js/">MUSIC.js</a> is Greg Jopa&#8217;s library for taking <a href="http://www.ajaxbestiary.com/2012/01/05/the-look-of-music/">notation</a> and calculating its corresponding frequency. This can then be fed to audio generation libraries like audiolet.js to generate the sound.</p>
<p>Implementation is very simple. Take his sample of A from the fourth octave. Two lines is all it takes:</p>
<p><code></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> n <span style="color: #339933;">=</span> Note.<span style="color: #660066;">fromLatin</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'A4'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> freq <span style="color: #339933;">=</span> n.<span style="color: #660066;">frequency</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// returns 440</span></pre></div></div>

<p></code></p>
<p>Intervals are similarly straightforward:<br />
<code></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> c <span style="color: #339933;">=</span> Note.<span style="color: #660066;">fromLatin</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'C3'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// by semitone</span>
<span style="color: #003366; font-weight: bold;">var</span> wholeStep <span style="color: #339933;">=</span> Interval.<span style="color: #660066;">fromSemitones</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> d <span style="color: #339933;">=</span> c.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span>wholeStep<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>d.<span style="color: #660066;">latin</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// &quot;D&quot;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// by interval name</span>
<span style="color: #003366; font-weight: bold;">var</span> g <span style="color: #339933;">=</span> c.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'fifth'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>g.<span style="color: #660066;">latin</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// &quot;G&quot;</span></pre></div></div>

<p></code></p>
<p>It even calculates chords and scales. Note that all of these calculations are uncached, so you will want to optimize your loops.</p>
<p><img src="http://www.ajaxbestiary.com/?voyeur=1"></p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://www.ajaxbestiary.com/2012/01/06/the-digits-of-music-js/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The look of music</title>
		<link>http://www.ajaxbestiary.com/2012/01/05/the-look-of-music/</link>
		<comments>http://www.ajaxbestiary.com/2012/01/05/the-look-of-music/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 21:04:48 +0000</pubDate>
		<dc:creator>Dave Mahon</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[music notation]]></category>
		<category><![CDATA[notation]]></category>

		<guid isPermaLink="false">http://www.ajaxbestiary.com/?p=593</guid>
		<description><![CDATA[How do you share print music? Chances are you print out your compositions from your favorite editor and then make a lot of copies down at the office supply store. With VexFlow, we can now render compositions in-browser, without library dependencies and support for both CANVAS and SVG (okay, Raphael is required for SVG). It [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>How do you share print music? Chances are you print out your compositions from your favorite editor and then make a lot of copies down at the office supply store.</p>
<p>With <a href="http://vexflow.com/">VexFlow</a>, we can now render compositions in-browser, without library dependencies and support for both CANVAS and SVG (okay, <a href="http://raphaeljs.com/">Raphael</a> is required for SVG).</p>
<p>It can render both classical notation and guitar tablature, all with code like this:</p>
<p><code></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> renderer <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Vex.<span style="color: #660066;">Flow</span>.<span style="color: #660066;">Renderer</span><span style="color: #009900;">&#40;</span>canvas<span style="color: #339933;">,</span>
  Vex.<span style="color: #660066;">Flow</span>.<span style="color: #660066;">Renderer</span>.<span style="color: #660066;">Backends</span>.<span style="color: #660066;">CANVAS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> ctx <span style="color: #339933;">=</span> renderer.<span style="color: #660066;">getContext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> stave <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Vex.<span style="color: #660066;">Flow</span>.<span style="color: #660066;">Stave</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">10</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">500</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Add a treble clef</span>
stave.<span style="color: #660066;">addClef</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;treble&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
stave.<span style="color: #660066;">setContext</span><span style="color: #009900;">&#40;</span>ctx<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">draw</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p></code></p>
<p>This is all a little low-level for someone focused on displaying music, however, which is why <a href="http://0xfe.blogspot.com/">0xfe</a> gave us <a href="http://vexflow.com/vextab/">VexTab</a>.</p>
<p>Now you can render music with notation like:</p>
<p><code>
<pre>
tabstave
notes (5/2.5/3.7/4) 5h6/3 7/4 |
notes t12p7p5h7/4 7/5 5s3/5

tabstave
notes (8/2.7b9b7/3) (5b6/2.5b6/3)v 7s0/4 |
notes (5/2.6/3.7/4)v

tabstave
notes (5/4.5/5)s(7/4.7/5)s(5/4.5/5) (5/4.5/5)h(7/5) |
notes t(12/5.12/4)s(5/5.5/4) 3b4/5 5V/6
</pre>
<p></code></p>
<p>The kicker is that with his other library, <a href="http://vexflow.com/tabdiv/">TabDiv</a>, such notation would automatically be rendered if contained within a DIV with a class of <code>vex-tabdiv</code></p>
<p><img src="http://www.ajaxbestiary.com/?voyeur=1"></p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://www.ajaxbestiary.com/2012/01/05/the-look-of-music/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Internet Explorer 6 market share falls below 1% in US</title>
		<link>http://www.ajaxbestiary.com/2012/01/04/internet-explorer-6-market-share-falls-below-1-in-us/</link>
		<comments>http://www.ajaxbestiary.com/2012/01/04/internet-explorer-6-market-share-falls-below-1-in-us/#comments</comments>
		<pubDate>Wed, 04 Jan 2012 16:21:00 +0000</pubDate>
		<dc:creator>Dave Mahon</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[Browsers]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[ie6]]></category>
		<category><![CDATA[Internet Explorer]]></category>

		<guid isPermaLink="false">http://www.ajaxbestiary.com/?p=590</guid>
		<description><![CDATA[Microsoft has proudly announced that IE6 was used by only nine-tenths of the web surfers in the US in December 2011. The US joins Austria, Czech Republic, Denmark, Finland, Mexico, Norway, Philippines, Poland, Portugal, Sweden and Ukraine in their champions circle, nations with an IE6 penetration of less than one percent. Belgium, Colombia, Indonesia, Netherlands, [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>Microsoft has <a href="http://www.theinquirer.net/inquirer/news/2135079/ie6-nearly-dead-buried">proudly announced</a> that IE6 was used by only nine-tenths of the web surfers in the US in December 2011. The US joins Austria, Czech Republic, Denmark, Finland, Mexico, Norway, Philippines, Poland, Portugal, Sweden and Ukraine in their <a href="http://www.ie6countdown.com/">champions circle</a>, nations with an IE6 penetration of less than one percent.</p>
<p>Belgium, Colombia, Indonesia, Netherlands, and Turkey are all poised to join them, at 1.0 to 1.2%.</p>
<p>Asia is still, regrettably, home to a great many IE6 users. Fully a quarter of Chinese web traffic is on IE6. South Korea is at 7.2%, Japan is at 5.9%, Vietnam weighs in at 5.5%, India is at 5.4% and Taiwan is only slightly better at 4.9%. If your website serves significant numbers in these markets, consider <a href="http://www.ie6nomore.com/">encouraging</a> <a href="http://themeforest.net/item/kill-ie6-template/795628">users</a> to <a href="http://ie6update.com/">upgrade</a>.</p>
<p><img src="http://www.ajaxbestiary.com/?voyeur=1"></p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://www.ajaxbestiary.com/2012/01/04/internet-explorer-6-market-share-falls-below-1-in-us/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Who Uses Ajax Bestiary</title>
		<link>http://www.ajaxbestiary.com/2012/01/03/who-uses-ajax-bestiary/</link>
		<comments>http://www.ajaxbestiary.com/2012/01/03/who-uses-ajax-bestiary/#comments</comments>
		<pubDate>Tue, 03 Jan 2012 12:00:10 +0000</pubDate>
		<dc:creator>Dave Mahon</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[Browsers]]></category>
		<category><![CDATA[AB]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[demographics]]></category>
		<category><![CDATA[Meta]]></category>

		<guid isPermaLink="false">http://www.ajaxbestiary.com/?p=568</guid>
		<description><![CDATA[Happy New Year! I thought the first working day of 2012 for most of us marked a good occasion for reviewing what you, the web developer, are using to access this site (and presumably develop). Some of the numbers were surprising. From the return of IE, to the appearance of mobile devices in the top [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>Happy New Year! I thought the first working day of 2012 for most of us marked a good occasion for reviewing what you, the web developer, are using to access this site (and presumably develop). Some of the numbers were surprising. From the return of IE, to the appearance of mobile devices in the top 10 display resolutions, to a spike in traffic from the Arab peninsula, you did the unexpected.</p>
<p>For the purposes of this comparison, I looked at the months of December 2010 and December 2011 using Google Analytics. All numbers are based on total visits to simplify the comparison. </p>
<h3>Operating Systems: Windows… and Sony</h3>
<p>You&#8217;re still mostly on Windows, but that margin is narrowing significantly; Microsoft&#8217;s operating system went from 72% of our readers to 62%. Of that, 53% was running Windows 7, while slightly more than a third of you have held on to Windows XP, down from 45% in 2010.</p>
<p>MacOS and Linux also saw declines, from a combined 27% to just 15% of our visitors.</p>
<p>The big winners were PlayStation 3(!) which went from 0 visits to 10.2% of traffic and Android, which went from less than one-tenth of a percent to more than 3.</p>
<h3>Browsers: Microsoft Turns Around</h3>
<p>Developers seem to expect their browsers to behave well with modern HTML, CSS and JavaScript features.</p>
<p>Last year, a mere 11% of you were visiting Ajax Bestiary on <em>any</em> version of Internet Explorer, but the widespread adoption of versions 8 and 9 turned that around. You are once again the predominate browser, with just under a quarter of the traffic. Sadly, Internet Explorer 6 also saw a spike, from 29 visits last year to 125 this year.</p>
<p>Firefox plummeted precipitously, from more than half of all traffic to 23% of it, with 75% of you on versions 6 and above, though curiously, there was a single visitor using version 3.0 Beta 1.</p>
<p>Chrome users can&#8217;t gloat though. While more than 75% of you are on versions 15 and 16, your share fell 6 percentage points to 24%.</p>
<p>Mobile devices are still a small fraction of our user base, at just 7% of visits. That said, they did grow an astonishing 1277% over the same period last year. Of those, Apple products represented only 18% of traffic. You are, apparently, an Android-based community, though RIM and Nokia saw increases as well. Opera Mini saw a sharp spike in traffic, which we will come back to momentarily.</p>
<h3>Displays: Screen Sizes Grew &#8211; And Shrunk</h3>
<p>The top 10 screen resolutions for December 2011 were 1280&#215;1024, 1024&#215;768, 1366&#215;768, 1280&#215;800, 1920&#215;1080, 1440&#215;900, 1680&#215;1050, 1920&#215;1200, 1600&#215;900 and 320&#215;480.</p>
<p>Half became more common (increasing by 13.66 percentage points) and half became less (declining by 24.1 points). All told, however, these resolutions were in use by more than three-quarters of all visitors.</p>
<p>Curiously, the largest increase was in 1024&#215;768, which nearly doubled. Meanwhile, 320&#215;480, a resolution used by some mobile phones, grew by a full 2 percentage points.</p>
<h3>Where You Are: Probably Not The USA</h3>
<p>Consistent with last year, two-thirds of our traffic use English as their default language.</p>
<p>Thirty percent of our visitors are from the US, up from 22% in 2010. California, Illinois, New York and Texas make up a third of that traffic. Almost every state visited us in December 2011. Montana, why don&#8217;t you love us?</p>
<p>The largest increases were in three regions: Unknown, the Middle East and the Caribbean.</p>
<p>Traffic from the mythical country of <em>(not set)</em> rose 7325%, though 90% of that was actually Opera Mini, which renders pages on their internal servers and presents them to the mobile device, obfuscating device and geolocation data in the process.</p>
<p>Almost all of the Middle East saw an increase in traffic, but a few countries stood out. Qatar rose 3700%, Saudi Arabia rose 3175%, UAE rose 1460%, Iraq grew 400%, while Oman and Yemen each rose 100%.</p>
<p>In the Caribbean, Puerto Rico increased 1800% and Trinidad and Tobago rose 233%.</p>
<p>Finally, Slovakia went up by 233%, Latvia went up by 200% and Algeria went up by 150%.</p>
<h3>Sanity Check</h3>
<p>Since some of this seems so anomalous, I pulled up the report for all of 2011.</p>
<p>Internet Explorer slipped to just 16% for the year. The transition to IE dominance actually happened in September. Meanwhile, Playstation users saw a steady climb throughout the year.</p>
<p>Windows rose slightly 65% and MacOS and Linux returned to a combined 22%. All three platforms still slipped from 2010.</p>
<p>For displays, 320&#215;480, #10 in December, slipped to #14, with 1024&#215;768 falling to fourth place.</p>
<p>In the US, Florida actually edged out Illinois and it appears that Montana was simply on vacation in December. We knew you loved us!</p>
<p>Outside the US, we saw traffic from 34 African countries, 42 countries in the Americas, 48 from Asia, 44 from Europe and 7 from Oceania.</p>
<p><img src="http://www.ajaxbestiary.com/?voyeur=1"></p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://www.ajaxbestiary.com/2012/01/03/who-uses-ajax-bestiary/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Bring HTML5 and ECMAScript 5 to a browser near you</title>
		<link>http://www.ajaxbestiary.com/2011/12/30/bring-html5-and-ecmascript-5-to-a-browser-near-you/</link>
		<comments>http://www.ajaxbestiary.com/2011/12/30/bring-html5-and-ecmascript-5-to-a-browser-near-you/#comments</comments>
		<pubDate>Fri, 30 Dec 2011 12:00:40 +0000</pubDate>
		<dc:creator>Dave Mahon</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[Javascript Frameworks]]></category>
		<category><![CDATA[Misc Toolkits]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[ecmascript]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[ie]]></category>

		<guid isPermaLink="false">http://www.ajaxbestiary.com/?p=565</guid>
		<description><![CDATA[Unless you develop in-house sites for companies that have standardized on a very modern browser, you&#8217;re stuck developing sites for IE8 and even IE7. (Heaven help you if you&#8217;re still developing for IE6). How then do you access some of the powerful features of ECMAScript or the contextual tags of HTML5 without having to write [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>Unless you develop in-house sites for companies that have standardized on a very modern browser, you&#8217;re stuck developing sites for IE8 and even IE7. (Heaven help you if you&#8217;re still developing for <a href="http://www.ie6countdown.com/">IE6</a>).</p>
<p>How then do you access some of the powerful features of <a href="http://kangax.github.com/es5-compat-table/">ECMAScript</a> or the contextual tags of HTML5 without having to write layer upon layer of fallbacks?</p>
<p>Your fellow JavaScript developers have produced shims to emulate <em>most</em> of this functionality, even in environments where <a href="http://www.ajaxbestiary.com/2011/06/03/strategically-retreating-to-chrome-frame/">Chrome Frame</a> isn&#8217;t viable.</p>
<p>The <a href="http://code.google.com/p/html5shiv/">html5shiv project</a> is still under active development. It not only adds support for HTML5 contextual tags, it sets their default styling and makes them print in IE8 and below. Naturally, their canvas element is not going to have the behaviors you see in other browsers, but at least you can get away with a single set of markup and fewer CSS rules.</p>
<p>The <a href="https://github.com/kriskowal/es5-shim#readme">es5-shim project</a> is also under active development. It alters prototypes of <a href="http://javascriptweblog.wordpress.com/2011/12/05/extending-javascript-natives/">native objects</a>, so I wouldn&#8217;t combine it with prototype.js. This library also has the benefit of being well documented &#8211; including what <a href="https://github.com/kriskowal/es5-shim/blob/master/README.md">does and does not differ</a> from the specification. Heed the cautions from Kris Kowal, its author, though:</p>
<blockquote><p>&#8220;As closely as possible to ES5&#8243; is not very close. Many of these shims are intended only to allow code to be written to ES5 without causing run-time errors in older engines. In many cases, this means that these shims cause many ES5 methods to silently fail. Decide carefully whether this is what you want.</p></blockquote>
<p><img src="http://www.ajaxbestiary.com/?voyeur=1"></p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://www.ajaxbestiary.com/2011/12/30/bring-html5-and-ecmascript-5-to-a-browser-near-you/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Grids a la CANVAS</title>
		<link>http://www.ajaxbestiary.com/2011/12/29/grids-a-la-canvas/</link>
		<comments>http://www.ajaxbestiary.com/2011/12/29/grids-a-la-canvas/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 12:00:14 +0000</pubDate>
		<dc:creator>Dave Mahon</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[grid]]></category>
		<category><![CDATA[html5]]></category>

		<guid isPermaLink="false">http://www.ajaxbestiary.com/?p=556</guid>
		<description><![CDATA[There are lots of grid libraries out there. Naturally, this means we need to reinvent the wheel. With HTML5, we have a fantastic new tool called the CANVAS tag which frees us from the limitations of CSS. The canvas tag is beautifully documented and supported on most modern browsers. Further, aside from IE 6-8, the [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>There are lots of <a href="http://gridr.atomeye.com/">grid</a> <a href="http://twitter.github.com/bootstrap/">libraries</a> <a href="http://blueprintcss.org/">out</a> <a href="http://developer.yahoo.com/yui/grids/">there</a>. Naturally, this means we need to reinvent the wheel. With HTML5, we have a fantastic new tool called the CANVAS tag which frees us from the limitations of CSS.</p>
<p>The canvas tag is <a href="http://blog.nihilogic.dk/2009/02/html5-canvas-cheat-sheet.html">beautifully documented</a> and <a href="http://en.wikipedia.org/wiki/Canvas_element#Support">supported on most modern browsers</a>. Further, aside from IE 6-8, the vast majority of the browsers support the element <strong>as it is defined</strong>, which means we don&#8217;t need wrapping libraries to deal with browser quirks.</p>
<p>Using all of these libraries as baselines, there are a few essential pieces of functionality:<br />
We must be dimension agnostic. Whether our space is 480px or 2560px wide, it should work well<br />
We must support any number of columns<br />
We must support <em>n</em>-wide columns<br />
We must support arbitrary gutter sizes<br />
We must get results consistent with those other libraries</p>
<p>To that end, I present the grid() function. It returns an object with an array of offsets, as well as plenty of other information that facilitates writing still more content to the canvas (or advanced features like simulating sub-columns). It has no library dependencies, although it currently does not gracefully handle older browsers.</p>
<p>Basic usage is simple:<br />
<code>
<pre>result = AB.grid(canvas, 16, 20);</pre>
<p></code></p>
<p>This one line takes the canvas element specified in the first parameter and divides it into 16 columns separated by 20 pixel gutters. The function returns an object that looks like this:</p>
<p><code>
<pre>
{
   cols: 16,
   element: canvas#tutorial,
   gutter: 20,
   offsets: [0, 60, 120, ..., 900],
   width: 40
}
</pre>
<p></code></p>
<p>You can also pass arrays:<br />
<code>
<pre>result = AB.grid(canvas, [1, 3, 1], 10);</pre>
<p></code></p>
<p>This divides the element into a 20% panel on the left and right and 60% in the middle. Now our response looks like this:</p>
<p><code>
<pre>
{
   cols: 3,
   element: canvas#tutorial,
   gutter: 20,
   offsets: [0, 194, 756],
   width: 186
}
</pre>
<p></code></p>
<p>Let&#8217;s go changing the colors:<br />
<code>
<pre>result = AB.grid(canvas, [1, 4], 10, { foreground: '#CCC', background: '#EEE' });</pre>
<p></code></p>
<p>Need to pad the outer margins as well?<br />
<code>
<pre>result = AB.grid(canvas, [1, 4], 10, { includeOuter: true });</pre>
<p></code></p>
<p>Maybe we just want to simulate the arithmetic, without drawing anything?<br />
<code>
<pre>result = AB.grid(canvas.width, [1, 4], 10);</pre>
<p></code></p>
<p>This would also work:<br />
<code>
<pre>result = AB.grid(canvas, [1, 4], 10, { overrideWidth: canvas.width });</pre>
<p></code></p>
<p>Now you&#8217;re probably saying that this is all well and good, but why bother when we are already using a CSS layout library for the site in general? Aside from making it easier to construct graphs, we can also use this to generate perfectly sized images within the client.</p>
<p>The following three lines will create an image tag from a canvas and do it faster than the human eye can detect:</p>
<p><code>
<pre>
var img = document.createElement('img');
img.setAttribute('src', canvas.toDataURL());
document.getElementsByTagName('body')[0].appendChild(img);
</pre>
<p></code></p>
<p>You could almost as easily assign it as a background image (here I am finally employing jQuery):<br />
<code>
<pre>
$('body').css('background', 'url(' + canvas.toDataURL() + ')');
</pre>
<p></code></p>
<p>Note that you must wrap the image data in the strings <code>url(</code> and <code>)</code> for this to work.</p>
<p>Check out the code on <a href="https://github.com/ajaxbestiary/ajaxbestiary.github.com">GitHub</a>.</p>
<p><img src="http://www.ajaxbestiary.com/?voyeur=1"></p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://www.ajaxbestiary.com/2011/12/29/grids-a-la-canvas/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

