<?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>Ajaxian &#187; Tip</title>
	<atom:link href="http://ajaxian.com/by/topic/tip/feed" rel="self" type="application/rss+xml" />
	<link>http://ajaxian.com</link>
	<description>Cleaning up the web with Ajax</description>
	<lastBuildDate>Tue, 22 May 2012 21:45:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
    	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>CSS calc() in the house</title>
		<link>http://ajaxian.com/archives/css-calc-in-the-house</link>
		<comments>http://ajaxian.com/archives/css-calc-in-the-house#comments</comments>
		<pubDate>Thu, 10 Jun 2010 15:51:37 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=9560</guid>
		<description><![CDATA[Finally. Don't make me jump to JavaScript to tweak the CSS when I want a relative calculation for a value. The effervescent Paul Rouget shows us the CSS calc() goodness that has a bug going for Mozilla. Some good simple use cases: PLAIN TEXT CSS: &#160; /* * Two divs aligned, split up by a <a href="http://ajaxian.com/archives/css-calc-in-the-house">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/paulcheek/503718869"><img src="http://ajaxian.com/wp-content/images/ticalc.jpg" alt="" title="ticalc" width="500" height="376" class="alignnone size-full wp-image-9562" /></a></p>
<p>Finally. Don't make me jump to JavaScript to tweak the CSS when I want a relative calculation for a value.</p>
<p>The effervescent Paul Rouget shows us the <a href="http://hacks.mozilla.org/2010/06/css3-calc/">CSS calc() goodness</a> that <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=363249">has a bug going for Mozilla</a>.</p>
<p>Some good simple use cases:</p>
<div class="igBar"><a href="javascript:showCodeTxt('css-2');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">CSS:</span>
<div id="css-2">
<div class="css">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/*</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">* Two divs aligned, split up by a 1em margin</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">*/</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #cc00cc;">#a <span style="color:#006600; font-weight:bold;">&#123;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000000; font-weight: bold;">width</span>:<span style="color:#800000;">75</span>%;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000000; font-weight: bold;">margin-right</span>: 1em;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #cc00cc;">#b <span style="color:#006600; font-weight:bold;">&#123;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000000; font-weight: bold;">width</span>: -moz-calc<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;">25</span>% - 1em<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/*</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"> * Make sure input field won't overlap parent</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"> */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">input <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000000; font-weight: bold;">padding</span>:2px;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; border<span style="color: #3333ff;">:1px </span>solid <span style="color: #000000; font-weight: bold;">black</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000000; font-weight: bold;">display</span>:<span style="color: #993333;">block</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000000; font-weight: bold;">width</span>: -moz-calc<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;">100</span>% - <span style="color:#800000;">2</span> * 3px<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/*</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"> * combine different units!</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"> */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">width</span>: -moz-calc<span style="color:#006600; font-weight:bold;">&#40;</span>3px + <span style="color:#800000;">50</span>%/<span style="color:#800000;">3</span> - 3em + 1rem<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>A lot of JavaScript is about to get nuked. It would be cool to have a pre-processor that generates JS code for browsers that won't support the syntax so we can use this not in 5 years.</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/css-calc-in-the-house/feed</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Canvas optimization tip: Get image data as infrequently as possible</title>
		<link>http://ajaxian.com/archives/canvas-image-data-optimization-tip</link>
		<comments>http://ajaxian.com/archives/canvas-image-data-optimization-tip#comments</comments>
		<pubDate>Thu, 27 May 2010 12:01:46 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Canvas]]></category>
		<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=9372</guid>
		<description><![CDATA[We have learned to touch the DOM as little as possible for performance sakes. Batch up changes, and do one call to innerHTML say. Talk over the evil boundary of the DOM as infrequently as possible. Well, Selim Arsever has found a similar tip for Canvas that caused a ~40% performance improvement on some of <a href="http://ajaxian.com/archives/canvas-image-data-optimization-tip">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p>We have learned to touch the DOM as little as possible for performance sakes. Batch up changes, and do one call to innerHTML say. Talk over the evil boundary of the DOM as infrequently as possible.</p>
<p>Well, Selim Arsever has <a href="http://www.onaluf.org/en/entry/13">found a similar tip for Canvas</a> that caused a ~40% performance improvement on some of his code. He had an example that did pixel twiddling, looking like:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-5');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-5">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">canvas = document.<span style="color: #006600;">getElementById</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"canvas"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">context = canvas.<span style="color: #006600;">getContext</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"2d"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">image = context.<span style="color: #006600;">getImageData</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;">0</span>, <span style="color:#800000;">0</span>, SCREEN_WIDTH, SCREEN_HEIGHT<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> pixels = SCREEN_WIDTH*SCREEN_HEIGHT;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000066; font-weight: bold;">while</span><span style="color:#006600; font-weight:bold;">&#40;</span>--pixels<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;image.<span style="color: #006600;">data</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;">4</span>*i+<span style="color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span> = r; <span style="color: #009900; font-style: italic;">// Red value</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;image.<span style="color: #006600;">data</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;">4</span>*i+<span style="color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span> = g; <span style="color: #009900; font-style: italic;">// Green value</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;image.<span style="color: #006600;">data</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;">4</span>*i+<span style="color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#93;</span> = b; <span style="color: #009900; font-style: italic;">// Blue value</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;image.<span style="color: #006600;">data</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;">4</span>*i+<span style="color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#93;</span> = a; <span style="color: #009900; font-style: italic;">// Alpha value</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">context.<span style="color: #006600;">putImageData</span><span style="color:#006600; font-weight:bold;">&#40;</span>image, <span style="color:#800000;">0</span>, <span style="color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>After listening to Stoyan talk perf, he wondered if there was an issue with the <code>image.data</code> access, and changed the code to:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-6');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-6">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">canvas = document.<span style="color: #006600;">getElementById</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"canvas"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">context = canvas.<span style="color: #006600;">getContext</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"2d"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">image = context.<span style="color: #006600;">getImageData</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;">0</span>, <span style="color:#800000;">0</span>, SCREEN_WIDTH, SCREEN_HEIGHT<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> pixels = SCREEN_WIDTH*SCREEN_HEIGHT;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> imageData = image.<span style="color: #006600;">data</span>; <span style="color: #009900; font-style: italic;">// here we detach the pixels array from DOM</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000066; font-weight: bold;">while</span><span style="color:#006600; font-weight:bold;">&#40;</span>--pixels<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;imageData<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;">4</span>*i+<span style="color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span> = r; <span style="color: #009900; font-style: italic;">// Red value</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;imageData<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;">4</span>*i+<span style="color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span> = g; <span style="color: #009900; font-style: italic;">// Green value</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;imageData<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;">4</span>*i+<span style="color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#93;</span> = b; <span style="color: #009900; font-style: italic;">// Blue value</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;imageData<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;">4</span>*i+<span style="color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#93;</span> = a; <span style="color: #009900; font-style: italic;">// Alpha value</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">image.<span style="color: #006600;">data</span> = imageData; <span style="color: #009900; font-style: italic;">// And here we attache it back </span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">context.<span style="color: #006600;">putImageData</span><span style="color:#006600; font-weight:bold;">&#40;</span>image, <span style="color:#800000;">0</span>, <span style="color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>He wrapped this all up in a benchmark that showed the perf diff. It actually really seemed to matter when using closures for namespaces:</p>
<p><img src="http://www.onaluf.org/media/canvas_benchmark.png"/></p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/canvas-image-data-optimization-tip/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>CSS Structural Reset</title>
		<link>http://ajaxian.com/archives/css-structural-reset</link>
		<comments>http://ajaxian.com/archives/css-structural-reset#comments</comments>
		<pubDate>Fri, 21 May 2010 11:55:58 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=9364</guid>
		<description><![CDATA[Browsers weren't given guidance in early HTML specs for default styles on elements. Does the body have a margin or a padding? What colors? etc. The easiest way to deal with multiple browser is so reset the CSS for them all, and built up from there. We then got Eric Meyer's reset and YUI reset <a href="http://ajaxian.com/archives/css-structural-reset">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p>Browsers weren't given guidance in early HTML specs for default styles on elements. Does the body have a margin or a padding? What colors? etc.</p>
<p>The easiest way to deal with multiple browser is so reset the CSS for them all, and built up from there. We then got <a href="http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/">Eric Meyer's reset</a> and <a href="http://developer.yahoo.com/yui/reset/">YUI reset</a> etc.</p>
<p>Vladimir Carrer just threw out his <a href="http://www.vcarrer.com/2010/05/css-mini-reset.html">mini reset</a> to handle the 80% rule:</p>
<div class="igBar"><a href="javascript:showCodeTxt('css-9');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">CSS:</span>
<div id="css-9">
<div class="css">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">html, body, div, form, fieldset, legend, label</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;<span style="color: #000000; font-weight: bold;">margin</span>: <span style="color:#800000;">0</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;<span style="color: #000000; font-weight: bold;">padding</span>: <span style="color:#800000;">0</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">table</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;<span style="color: #000000; font-weight: bold;">border-collapse</span>: <span style="color: #993333;">collapse</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;<span style="color: #000000; font-weight: bold;">border-spacing</span>: <span style="color:#800000;">0</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">th, td</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;<span style="color: #000000; font-weight: bold;">text-align</span>: <span style="color: #000000; font-weight: bold;">left</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;<span style="color: #000000; font-weight: bold;">vertical-align</span>: <span style="color: #000000; font-weight: bold;">top</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">h1, h2, h3, h4, h5, h6, th, td, caption <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color: #000000; font-weight: bold;">font-weight</span>:<span style="color: #993333;">normal</span>; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">img <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color: #000000; font-weight: bold;">border</span>: <span style="color:#800000;">0</span>; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>Folks comments on their own tweaks, including the minimal:</p>
<div class="igBar"><a href="javascript:showCodeTxt('css-10');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">CSS:</span>
<div id="css-10">
<div class="css">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">* <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color: #000000; font-weight: bold;">vertical-align</span>: <span style="color: #993333;">baseline</span>; <span style="color: #000000; font-weight: bold;">font-weight</span>: <span style="color: #993333;">inherit</span>; <span style="color: #000000; font-weight: bold;">font-family</span>: <span style="color: #993333;">inherit</span>; <span style="color: #000000; font-weight: bold;">font-style</span>: <span style="color: #993333;">inherit</span>; <span style="color: #000000; font-weight: bold;">font-size</span>: <span style="color:#800000;">100</span>%; <span style="color: #000000; font-weight: bold;">border</span>: <span style="color:#800000;">0</span>; <span style="color: #000000; font-weight: bold;">padding</span>: <span style="color:#800000;">0</span>; <span style="color: #000000; font-weight: bold;">margin</span>: <span style="color:#800000;">0</span>; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>What reset do you use?</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/css-structural-reset/feed</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Gmail Mobile team talks Latency and Code Loading</title>
		<link>http://ajaxian.com/archives/gmail-mobile-latency</link>
		<comments>http://ajaxian.com/archives/gmail-mobile-latency#comments</comments>
		<pubDate>Tue, 22 Sep 2009 11:09:43 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=7404</guid>
		<description><![CDATA[Bikin Chiu of the Gmail Mobile team picks up the HTML5 series with a piece on reducing startup latency. It starts off by talking about lazily loading code via the old favorites of adding a &#60;script&#62; to the DOM, or XHR+eval, but then it gets beyond the typical and discusses the nuance of mobile + <a href="http://ajaxian.com/archives/gmail-mobile-latency">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p>Bikin Chiu of the Gmail Mobile team picks up the HTML5 series with a piece on <a href="http://googlecode.blogspot.com/2009/09/gmail-for-mobile-html5-series-reducing.html">reducing startup latency</a>.</p>
<p>It starts off by talking about lazily loading code via the old favorites of adding a &lt;script&gt; to the DOM, or XHR+eval, but then it gets beyond the typical and discusses the nuance of mobile + offline caching. The hack that is used, is another oldie.... which is to hide the script and eval it later:</p>
<blockquote><p>
For an HTML 5 application that takes advantage of the application cache to reduce startup latency and to serve the application offline, there are a few caveats one should be aware of. Mobile networks have decent bandwidth, but poor round trip latency, so listing each module as a separate resource in the manifest incurs quite a bit of extra startup latency when the application cache is empty. Also, if one of the module resources fails to be downloaded by the application cache (e.g. disconnected from network), additional error handling code needs to be written to handle such a case. Finally, applications today have no control when the application cache decides to download the resources in the manifest (such a feature is not defined in the current specification of the draft standard). Typically, resources are downloaded once the main page is loaded, but that's not an ideal time since that's when the application requests user data.</p>
<p>To work-around these caveats, we found a trick that allows you to bundle all of your modules into a single resource without having to parse any of the JavaScript. Of course, with this strategy, there is greater latency with the initial download of the single resource (since it has all your JavaScript modules), but once the resource is stored in the browser's application cache, this issue becomes much less of a factor.</p>
<p>To combine all modules into a single resource, we wrote each module into a separate script tag and hid the code inside a comment block (/* */). When the resource first loads, none of the code is parsed since it is commented out. To load a module, find the DOM element for the corresponding script tag, strip out the comment block, and eval() the code. If the web app supports XHTML, this trick is even more elegant as the modules can be hidden inside a CDATA tag instead of a script tag. An added bonus is the ability to lazy load your modules synchronously since there's no longer a need to fetch the modules asynchronously over the network.</p>
<p>On an iPhone 2.2 device, 200k of JavaScript held within a block comment adds 240ms during page load, whereas 200k of JavaScript that is parsed during page load added 2600 ms. That's more than a 10x reduction in startup latency by eliminating 200k of unneeded JavaScript during page load! Take a look at the code sample below to see how this is done. </p>
<div class="igBar"><a href="javascript:showCodeTxt('html-12');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">HTML:</span>
<div id="html-12">
<div class="html">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"lazy"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">// Make sure you strip out (or replace) comment blocks in your JavaScript first.</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">/*</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">JavaScript of lazy module</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">*/</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script&gt;</span></a></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; function lazyLoad() {</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; var lazyElement = document.getElementById('lazy');</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; var lazyElementBody = lazyElement.innerHTML;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; var jsCode = stripOutCommentBlock(lazyElementBody);</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; eval(jsCode);</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; }</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>In the future, we hope that the HTML5 standard will allow more control over when the application cache should download resources in the manifest, since using comments to pass along code is not elegant but worked nicely for us.
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/gmail-mobile-latency/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>FireCrystal: Observe and roll back interactions</title>
		<link>http://ajaxian.com/archives/firecrystal-observe-and-roll-back-interactions</link>
		<comments>http://ajaxian.com/archives/firecrystal-observe-and-roll-back-interactions#comments</comments>
		<pubDate>Wed, 02 Sep 2009 11:52:18 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Tip]]></category>
		<category><![CDATA[Utility]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=7312</guid>
		<description><![CDATA[FireCrystal is a Firefox extension that helps designers and programmers alike figure out how interactive behaviors on the web work. FireCrystal allows users to record and rewind their interactions with web pages while showing the relevant code.]]></description>
			<content:encoded><![CDATA[<p><a href="http://stephenoney.com/images/firecrystal_nyt.png"></p>
<p></a><a href="http://stephenoney.com/firecrystal.php">FireCrystal</a> is a Firefox extension that helps designers and programmers alike figure out how interactive behaviors on the web work. FireCrystal allows users to record and rewind their interactions with web pages while showing the relevant code.</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/firecrystal-observe-and-roll-back-interactions/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Text rotation for all</title>
		<link>http://ajaxian.com/archives/text-rotation-for-all</link>
		<comments>http://ajaxian.com/archives/text-rotation-for-all#comments</comments>
		<pubDate>Wed, 29 Jul 2009 15:20:59 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=7154</guid>
		<description><![CDATA[Jonathan Snook has posted a nice nugget on text rotation with CSS that takes a nice bit of markup like this: PLAIN TEXT HTML: &#160; &#60;div class="example-date"&#62; &#160; &#60;span class="day"&#62;31&#60;/span&#62; &#160; &#60;span class="month"&#62;July&#60;/span&#62; &#160; &#60;span class="year"&#62;2009&#60;/span&#62; &#60;/div&#62; &#160; and converts it to: all via the CSS: PLAIN TEXT CSS: &#160; -webkit-transform: rotate&#40;-90deg&#41;; -moz-transform: rotate&#40;-90deg&#41;; filter: <a href="http://ajaxian.com/archives/text-rotation-for-all">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://twitter.com/snookca">Jonathan Snook</a> has posted a nice nugget on <a href="http://snook.ca/archives/html_and_css/css-text-rotation">text rotation with CSS</a> that takes a nice bit of markup like this:</p>
<div class="igBar"><a href="javascript:showCodeTxt('html-15');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">HTML:</span>
<div id="html-15">
<div class="html">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"example-date"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/span.html"><span style="color: #000000; font-weight: bold;">&lt;span</span></a> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"day"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span>31<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/span&gt;</span></span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/span.html"><span style="color: #000000; font-weight: bold;">&lt;span</span></a> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"month"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span>July<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/span&gt;</span></span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/span.html"><span style="color: #000000; font-weight: bold;">&lt;span</span></a> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"year"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span>2009<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/span&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>and converts it to:</p>
<p><img src="http://snook.ca/technical/text-rotation/text-rotation.png"/></p>
<p>all via the CSS:</p>
<div class="igBar"><a href="javascript:showCodeTxt('css-16');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">CSS:</span>
<div id="css-16">
<div class="css">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">-webkit-transform: rotate<span style="color:#006600; font-weight:bold;">&#40;</span>-90deg<span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">-moz-transform: rotate<span style="color:#006600; font-weight:bold;">&#40;</span>-90deg<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">filter: progid:DXImageTransform.Microsoft.BasicImage<span style="color:#006600; font-weight:bold;">&#40;</span>rotation=<span style="color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>Yup, even IE.</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/text-rotation-for-all/feed</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
		<item>
		<title>More than you ever want to see about encoding</title>
		<link>http://ajaxian.com/archives/encoding</link>
		<comments>http://ajaxian.com/archives/encoding#comments</comments>
		<pubDate>Thu, 02 Jul 2009 10:03:19 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Tip]]></category>
		<category><![CDATA[Utility]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=7043</guid>
		<description><![CDATA[Paul Baukaus linked to jsescape, a little form that shows escaping and unescaping across a number of encodings. Andrea Giammarchi had his own post on encodings in a different way.... as he talked about en-code which you can check out in action here on the page that lets you do simple encodings, especially for source <a href="http://ajaxian.com/archives/encoding">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p>Paul Baukaus linked to <a href="http://0xcc.net/jsescape/">jsescape</a>, a little form that shows escaping and unescaping across a number of encodings.</p>
<p><img src="http://ajaxian.com/wp-content/uploads/encodings.png" alt="" title="encodings" width="488" height="802" class="alignnone size-full wp-image-7044" /></p>
<p>Andrea Giammarchi had his own post on encodings in a different way.... as he talked about<br />
<a href="http://webreflection.blogspot.com/2009/05/en-code-quickest-way-to-encode-your.html">en-code</a> which you can <a href="http://www.3site.eu/encode/">check out in action here</a> on the page that lets you do simple encodings, especially for source code, in short order.</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/encoding/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>CSS Browser Hacks</title>
		<link>http://ajaxian.com/archives/css-browser-hacks</link>
		<comments>http://ajaxian.com/archives/css-browser-hacks#comments</comments>
		<pubDate>Fri, 24 Apr 2009 15:35:21 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=6646</guid>
		<description><![CDATA[Paul Irish tries not to use CSS browser hacks anymore and instead "uses IE's conditional comments to apply classes to the body tag, but he put up a concise list of browser specific hacks he has used: PLAIN TEXT CSS: &#160; /***** Selector Hacks ******/ &#160; /* IE 6 and below */ * html #uno&#160; <a href="http://ajaxian.com/archives/css-browser-hacks">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p>Paul Irish tries not to use CSS browser hacks anymore and instead "<a href="http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/">uses IE's conditional comments to apply classes to the body tag</a>, but he put up a concise list of <a href="http://paulirish.com/2009/browser-specific-css-hacks/">browser specific hacks he has used</a>:</p>
<div class="igBar"><a href="javascript:showCodeTxt('css-18');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">CSS:</span>
<div id="css-18">
<div class="css">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/***** Selector Hacks ******/</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* IE 6 and below */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">* html <span style="color: #cc00cc;">#uno&nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></span> <span style="color: #000000; font-weight: bold;">color</span>: <span style="color: #993333;">red</span> <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* IE 7 and below */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">*:first-child+html <span style="color: #cc00cc;">#dos <span style="color:#006600; font-weight:bold;">&#123;</span></span> <span style="color: #000000; font-weight: bold;">color</span>: <span style="color: #993333;">red</span> <span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* IE 7 and modern browsers */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">html&gt;body <span style="color: #cc00cc;">#tres <span style="color:#006600; font-weight:bold;">&#123;</span></span> <span style="color: #000000; font-weight: bold;">color</span>: <span style="color: #993333;">red</span> <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* Modern browsers (not IE 7) */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">html&gt;<span style="color: #808080; font-style: italic;">/**/</span>body <span style="color: #cc00cc;">#cuatro <span style="color:#006600; font-weight:bold;">&#123;</span></span> <span style="color: #000000; font-weight: bold;">color</span>: <span style="color: #993333;">red</span> <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* Opera 9.27 and below */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">html<span style="color: #3333ff;">:first-child </span><span style="color: #cc00cc;">#cinco <span style="color:#006600; font-weight:bold;">&#123;</span></span> <span style="color: #000000; font-weight: bold;">color</span>: <span style="color: #993333;">red</span> <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* Safari */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">html<span style="color:#006600; font-weight:bold;">&#91;</span>xmlns*=<span style="color: #ff0000;">""</span><span style="color:#006600; font-weight:bold;">&#93;</span> body<span style="color: #3333ff;">:last-child </span><span style="color: #cc00cc;">#seis <span style="color:#006600; font-weight:bold;">&#123;</span></span> <span style="color: #000000; font-weight: bold;">color</span>: <span style="color: #993333;">red</span> <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/*safari 3+, chrome 1+, opera9+, ff 3.5+ */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">body:nth-of-type<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #cc00cc;">#siete <span style="color:#006600; font-weight:bold;">&#123;</span></span> <span style="color: #000000; font-weight: bold;">color</span>: <span style="color: #993333;">red</span> <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* safari 3+, chrome 1+, opera9+, ff 3.5+ */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">body<span style="color: #3333ff;">:first-of-type </span><span style="color: #cc00cc;">#ocho <span style="color:#006600; font-weight:bold;">&#123;</span></span>&nbsp; <span style="color: #000000; font-weight: bold;">color</span>: <span style="color: #993333;">red</span> <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* saf3, chrome1+ */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">@media screen and (-webkit-min-device-pixel-ratio:0) {</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;<span style="color: #cc00cc;">#diez&nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></span> <span style="color: #000000; font-weight: bold;">background</span>: #FFDECE; <span style="color: #000000; font-weight: bold;">border</span>: 2px <span style="color: #993333;">solid</span> #ff0000&nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/***** Attribute Hacks ******/</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* ie6 and below */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #cc00cc;">#once <span style="color:#006600; font-weight:bold;">&#123;</span></span> _color<span style="color: #3333ff;">:<span style="color: #000000; font-weight: bold;">blue</span> </span><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* ie7 and below */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #cc00cc;">#doce <span style="color:#006600; font-weight:bold;">&#123;</span></span> *<span style="color: #000000; font-weight: bold;">color</span>: <span style="color: #000000; font-weight: bold;">blue</span> <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color: #808080; font-style: italic;">/* or #color:blue */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* 'Modern Browsers' includes IE8, whether you agree or not.. :) */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>He has included a <a href="http://paulirish.com/work/csshacks.html">test page</a> and you can view the <a href="http://browsershots.org/http://paulirish.com/work/csshacks.html">different browsers via browsershots</a>.</p>
<p>Finally, he links to another concise list... of <a href="http://www.thespanner.co.uk/2009/01/29/detecting-browsers-javascript-hacks/">JavaScript sniffs</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/css-browser-hacks/feed</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>How many ways can you iterate over an array in JavaScript?</title>
		<link>http://ajaxian.com/archives/how-many-ways-can-you-iterate-over-an-array-in-javascript</link>
		<comments>http://ajaxian.com/archives/how-many-ways-can-you-iterate-over-an-array-in-javascript#comments</comments>
		<pubDate>Thu, 23 Apr 2009 09:29:51 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=6643</guid>
		<description><![CDATA[Myk is one of the nicest chaps that I have had the pleasure to sit closely to in Mozilla building "S". He has a nice little tip on the many syntaxes that you can use to iterate over arrays in various JavaScript implementations and standards. Some folks had some interesting points on the various approaches: <a href="http://ajaxian.com/archives/how-many-ways-can-you-iterate-over-an-array-in-javascript">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p>Myk is one of the nicest chaps that I have had the pleasure to sit closely to in Mozilla building "S".</p>
<p>He has a nice little tip on <a href="http://www.melez.com/mykzilla/2009/04/syntaxes-for-iterating-arrays-in.html">the many syntaxes that you can use to iterate over arrays in various JavaScript implementations and standards</a>. Some folks had some interesting points on the various approaches:</p>
<blockquote>
<p><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Statements/for_each...in">for each in</a>:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-25');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-25">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000066; font-weight: bold;">for</span> each <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> <span style="color: #000066; font-weight: bold;">item</span> <span style="color: #000066; font-weight: bold;">in</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;">1</span>, <span style="color:#800000;">2</span>, <span style="color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #000066;">alert</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>The MDC docs for "for each" say not to iterate arrays that way, too, so I never use it on them. The usual (would need to guard with <code>hasOwnProperty()</code> issue).</p>
<p><a href="https://developer.mozilla.org/en/New_in_JavaScript_1.6">JavaScript 1.6</a> added the <a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array/forEach">Array.forEach method</a>:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-26');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-26">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;">1</span>, <span style="color:#800000;">2</span>, <span style="color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color: #006600;">forEach</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color: #000066;">alert</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p><a href="https://developer.mozilla.org/En/New_in_JavaScript_1.7">JavaScript 1.7</a> added <a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Working_with_Arrays#Array_comprehensions">array comprehensions</a> for array initialization:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-27');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-27">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> squares = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color: #000066; font-weight: bold;">item</span> * <span style="color: #000066; font-weight: bold;">item</span> <span style="color: #000066; font-weight: bold;">for</span> each <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span> <span style="color: #000066; font-weight: bold;">in</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;">1</span>, <span style="color:#800000;">2</span>, <span style="color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>I just realized I can (ab)use comprehensions to iterate arrays with Perl-like syntax by throwing away the result:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-28');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-28">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color: #000066;">alert</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #000066; font-weight: bold;">for</span> each <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span> <span style="color: #000066; font-weight: bold;">in</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;">1</span>, <span style="color:#800000;">2</span>, <span style="color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>I can iterate object properties the same way:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-29');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-29">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> obj = <span style="color:#006600; font-weight:bold;">&#123;</span> foo: <span style="color:#800000;">1</span>, bar: <span style="color:#800000;">2</span>, baz: <span style="color:#800000;">3</span> <span style="color:#006600; font-weight:bold;">&#125;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color: #000066;">alert</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #000066;">name</span> + <span style="color: #3366CC;">"="</span> + obj<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color: #000066;">name</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #000066; font-weight: bold;">for</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #000066;">name</span> <span style="color: #000066; font-weight: bold;">in</span> obj<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>Edward Lee points out how to use Iterators:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-30');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-30">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color: #000066;">alert</span><span style="color:#006600; font-weight:bold;">&#40;</span>key + <span style="color: #3366CC;">"="</span> + val<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #000066; font-weight: bold;">for</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span>key, val<span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color: #000066; font-weight: bold;">in</span> Iterator<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#123;</span>a:<span style="color:#800000;">1</span>,b:<span style="color:#800000;">2</span>,c:<span style="color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/how-many-ways-can-you-iterate-over-an-array-in-javascript/feed</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Detecting event support in browsers</title>
		<link>http://ajaxian.com/archives/detecting-event-support-in-browsers</link>
		<comments>http://ajaxian.com/archives/detecting-event-support-in-browsers#comments</comments>
		<pubDate>Fri, 03 Apr 2009 12:19:57 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=6487</guid>
		<description><![CDATA[Kangax has a really nice article on testing for event support in browsers in which he delves into the quirks and work-arounds needed to get 'er done, coming up with a nice generic solution: PLAIN TEXT JAVASCRIPT: &#160; &#160; var isEventSupported = &#40;function&#40;&#41;&#123; &#160; &#160; var TAGNAMES = &#123; &#160; &#160; &#160; 'select':'input','change':'input', &#160; &#160; <a href="http://ajaxian.com/archives/detecting-event-support-in-browsers">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p>Kangax <a href="http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/">has a really nice article on testing for event support in browsers</a> in which he delves into the quirks and work-arounds needed to get 'er done, coming up with a nice generic solution:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-32');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-32">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #003366; font-weight: bold;">var</span> isEventSupported = <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> TAGNAMES = <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">'select'</span>:<span style="color: #3366CC;">'input'</span>,<span style="color: #3366CC;">'change'</span>:<span style="color: #3366CC;">'input'</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">'submit'</span>:<span style="color: #3366CC;">'form'</span>,<span style="color: #3366CC;">'reset'</span>:<span style="color: #3366CC;">'form'</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">'error'</span>:<span style="color: #3366CC;">'img'</span>,<span style="color: #3366CC;">'load'</span>:<span style="color: #3366CC;">'img'</span>,<span style="color: #3366CC;">'abort'</span>:<span style="color: #3366CC;">'img'</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">function</span> isEventSupported<span style="color:#006600; font-weight:bold;">&#40;</span>eventName<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> el = document.<span style="color: #006600;">createElement</span><span style="color:#006600; font-weight:bold;">&#40;</span>TAGNAMES<span style="color:#006600; font-weight:bold;">&#91;</span>eventName<span style="color:#006600; font-weight:bold;">&#93;</span> || <span style="color: #3366CC;">'div'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; eventName = <span style="color: #3366CC;">'on'</span> + eventName;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> isSupported = <span style="color:#006600; font-weight:bold;">&#40;</span>eventName <span style="color: #000066; font-weight: bold;">in</span> el<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>!isSupported<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; el.<span style="color: #006600;">setAttribute</span><span style="color:#006600; font-weight:bold;">&#40;</span>eventName, <span style="color: #3366CC;">'return;'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; isSupported = <span style="color: #000066; font-weight: bold;">typeof</span> el<span style="color:#006600; font-weight:bold;">&#91;</span>eventName<span style="color:#006600; font-weight:bold;">&#93;</span> == <span style="color: #3366CC;">'function'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; el = <span style="color: #003366; font-weight: bold;">null</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> isSupported;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> isEventSupported;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>Along with this, he put up a <a href="http://yura.thinkweb2.com/isEventSupported/">simple test case</a> that you can point at.</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/detecting-event-support-in-browsers/feed</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Calculate your content to markup ratio</title>
		<link>http://ajaxian.com/archives/calculate-your-content-to-markup-ratio</link>
		<comments>http://ajaxian.com/archives/calculate-your-content-to-markup-ratio#comments</comments>
		<pubDate>Fri, 06 Mar 2009 07:58:28 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Tip]]></category>
		<category><![CDATA[Utility]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=6193</guid>
		<description><![CDATA[Stoyan Stefanov has created a fun little bookmarklet that calculates the content to markup ratio of a webpage: When you care about performance, or SEO (or just doing a good job as web dev) an interesting data point is the ratio of page content vs. the markup used to present this content. Or... how much <a href="http://ajaxian.com/archives/calculate-your-content-to-markup-ratio">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p>Stoyan Stefanov has created a fun little bookmarklet that <a href="http://www.phpied.com/content-to-markup-ratio-bookmarklet/">calculates the content to markup ratio</a> of a webpage:</p>
<blockquote><p>
When you care about performance, or SEO (or just doing a good job as web dev) an interesting data point is the ratio of page content vs. the markup used to present this content. Or... how much crap we put in HTML in order to present what the users want to see - the content.</p>
<p>So I played tonight with a bookmarklet to provide this piece of stats.</p>
<p>The bookmarklet code is served from <a href="http://phpied.com/files/bookmarklets/content2markup.js">here</a>. The code is also on <a href="http://github.com/stoyan/etc/blob/master/content2markup/content2markup.js">github</a>.
</p></blockquote>
<p>And some fun results:</p>
<p>Here are some random results of running the bookmarklet on different sites.</p>
<p>http://www.cnn.com:<br />
Total size: 92004 bytes<br />
Content size: 11475 bytes<br />
Content-to-markup ratio: 0.12<br />
Fair ratio * : 0.16</p>
<p>http://www.sitepoint.com</p>
<p>Total size: 65989 bytes<br />
Content size: 16199 bytes<br />
Content-to-markup ratio: 0.25<br />
Fair ratio * : 0.60</p>
<p>Article on http://en.wikipedia.org:<br />
Total size: 21648 bytes<br />
Content size: 3315 bytes<br />
Content-to-markup ratio: 0.15<br />
Fair ratio * : 0.35</p>
<p>http://www.phpied.com<br />
Total size: 31899 bytes<br />
Content size: 7933 bytes<br />
Content-to-markup ratio: 0.25<br />
Fair ratio * : 0.48</p>
<p>http://www.google.com SERP<br />
Total size: 29963 bytes<br />
Content size: 3351 bytes<br />
Content-to-markup ratio: 0.11<br />
Fair ratio * : 0.14</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/calculate-your-content-to-markup-ratio/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Watching Prototype events and a nice little tip</title>
		<link>http://ajaxian.com/archives/watching-prototype-events-and-a-nice-little-tip</link>
		<comments>http://ajaxian.com/archives/watching-prototype-events-and-a-nice-little-tip#comments</comments>
		<pubDate>Mon, 23 Feb 2009 11:56:09 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Prototype]]></category>
		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=6063</guid>
		<description><![CDATA[Kangax shows a nice use of Prototype as he writes a tip to let you see your Prototype based events as they run in your application. A nice little view. He also realized that the core piece of the bookmarklet is actually a nice view of the power of Prototype as a library: PLAIN TEXT <a href="http://ajaxian.com/archives/watching-prototype-events-and-a-nice-little-tip">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p>Kangax shows a nice use of Prototype as he <a href="http://thinkweb2.com/projects/prototype/event-delegation-will-save-the-world/">writes a tip to let you see your Prototype based events</a> as they run in your application. A nice little view.</p>
<p>He also realized that the core piece of the <a href="javascript:alert($H(Event.cache).inject(0,function(m,p){m+=$H(p.value).values().flatten().size();return%20m}))">bookmarklet</a> is actually a nice view of the power of Prototype as a library:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-34');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-34">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">$H<span style="color:#006600; font-weight:bold;">&#40;</span>Event.<span style="color: #006600;">cache</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #006600;">inject</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;">0</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color:#006600; font-weight:bold;">&#40;</span>m, p<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; m += $H<span style="color:#006600; font-weight:bold;">&#40;</span>p.<span style="color: #006600;">value</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #006600;">values</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #006600;">flatten</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #006600;">size</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000066; font-weight: bold;">return</span> m;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/watching-prototype-events-and-a-nice-little-tip/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>HTML5 Canvas Cheat Sheet</title>
		<link>http://ajaxian.com/archives/html5-canvas-cheat-sheet</link>
		<comments>http://ajaxian.com/archives/html5-canvas-cheat-sheet#comments</comments>
		<pubDate>Mon, 23 Feb 2009 05:56:37 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Canvas]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=6065</guid>
		<description><![CDATA[Jacob is back, and this time he has a cheat sheet with him. It is nice to see the Canvas API fitting on one sheet here, and I really like the images showing how things look like and work.]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.nihilogic.dk/2009/02/html5-canvas-cheat-sheet.html"><img src="http://ajaxian.com/wp-content/uploads/canvascheatsheet.png" alt="" title="canvas cheat sheet" width="472" height="698" class="alignnone size-full wp-image-6066" /></a></p>
<p>Jacob is back, and this time he has <a href="http://blog.nihilogic.dk/2009/02/html5-canvas-cheat-sheet.html">a cheat sheet with him</a>. It is nice to see the Canvas API fitting on one sheet here, and I really like the images showing how things look like and work.</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/html5-canvas-cheat-sheet/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>IE=&#8217;\v&#8217;==&#8217;v&#8217;</title>
		<link>http://ajaxian.com/archives/ievv</link>
		<comments>http://ajaxian.com/archives/ievv#comments</comments>
		<pubDate>Thu, 29 Jan 2009 06:02:52 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=5826</guid>
		<description><![CDATA[PLAIN TEXT JAVASCRIPT: &#160; IE='\v'=='v' &#160; That is the current winner in the shortest way to test for IE (including 8). The other notable was: PLAIN TEXT JAVASCRIPT: &#160; IE=top.execScript?1:0 &#160; Huh :) Gareth Heyes (the chap who did the v trick) has posted on this himself and comes up with One Line To Rule <a href="http://ajaxian.com/archives/ievv">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<div class="igBar"><a href="javascript:showCodeTxt('javascript-38');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-38">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">IE=<span style="color: #3366CC;">'<span style="color: #000099; font-weight: bold;">\v</span>'</span>==<span style="color: #3366CC;">'v'</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>That is the current winner in the <a href="http://webreflection.blogspot.com/2009/01/32-bytes-to-know-if-your-browser-is-ie.html">shortest way to test for IE</a> (including 8). The other notable was:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-39');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-39">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">IE=top.<span style="color: #006600;">execScript</span>?<span style="color:#800000;">1</span>:<span style="color:#800000;">0</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>Huh :)</p>
<p>Gareth Heyes (the chap who did the v trick) has <a href="http://www.thespanner.co.uk/2009/01/29/detecting-browsers-javascript-hacks/">posted on this himself</a> and comes up with One Line To Rule Them All:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-40');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-40">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">B=<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> x<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#91;</span>-<span style="color:#800000;">5</span><span style="color:#006600; font-weight:bold;">&#93;</span>==<span style="color: #3366CC;">'x'</span>?<span style="color: #3366CC;">'FF3'</span>:<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> x<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#91;</span>-<span style="color:#800000;">6</span><span style="color:#006600; font-weight:bold;">&#93;</span>==<span style="color: #3366CC;">'x'</span>?<span style="color: #3366CC;">'FF2'</span>:<span style="color: #0066FF;">/a/</span><span style="color:#006600; font-weight:bold;">&#91;</span>-<span style="color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span>==<span style="color: #3366CC;">'a'</span>?<span style="color: #3366CC;">'FF'</span>:<span style="color: #3366CC;">'<span style="color: #000099; font-weight: bold;">\v</span>'</span>==<span style="color: #3366CC;">'v'</span>?<span style="color: #3366CC;">'IE'</span>:<span style="color: #0066FF;">/a/</span>.__proto__==<span style="color: #3366CC;">'//'</span>?<span style="color: #3366CC;">'Saf'</span>:<span style="color: #0066FF;">/s/.<span style="color: #006600;">test</span><span style="color:#006600; font-weight:bold;">&#40;</span>/a/</span>.<span style="color: #006600;">toString</span><span style="color:#006600; font-weight:bold;">&#41;</span>?<span style="color: #3366CC;">'Chr'</span>:<span style="color: #0066FF;">/^<span style="color: #003366; font-weight: bold;">function</span> \<span style="color:#006600; font-weight:bold;">&#40;</span>/</span>.<span style="color: #006600;">test</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color: #006600;">sort</span><span style="color:#006600; font-weight:bold;">&#41;</span>?<span style="color: #3366CC;">'Op'</span>:<span style="color: #3366CC;">'Unknown'</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/ievv/feed</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Browser Detection with XSLT</title>
		<link>http://ajaxian.com/archives/browser-detection-with-xslt</link>
		<comments>http://ajaxian.com/archives/browser-detection-with-xslt#comments</comments>
		<pubDate>Tue, 27 Jan 2009 10:50:21 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Tip]]></category>
		<category><![CDATA[xsl]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=5797</guid>
		<description><![CDATA[This is a fun little hack by Manfred Staudinger. Thanks to select="system-property('xsl:vendor')", he has a style sheet that allows you to show items depending on the browser: To include a link or a style element for one of the above choices you use the dr:select attribute and specify one or more tokens as a comma <a href="http://ajaxian.com/archives/browser-detection-with-xslt">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p><img src="http://ajaxian.com/wp-content/uploads/xslbrowsercheck.png" alt="" title="xslbrowsercheck" width="500" height="310" class="alignnone size-full wp-image-5798" /></p>
<p>This is a fun little hack by Manfred Staudinger.</p>
<p>Thanks to <code>select="system-property('xsl:vendor')"</code>, he has a <a href="http://documenta.rudolphina.org/c-cond-html.xsl">style sheet</a> that allows you to <a href="http://documenta.rudolphina.org/cond-css-demo.xml">show items depending on the browser</a>:</p>
<blockquote><p>
To include a link or a style element for one of the above choices you use the dr:select attribute and specify one or more tokens as a comma separated list. For example dr:select="Firefox, Safari 3" will cause the link or style element to be included for any Firefox and for Safari 3. If you specify more than one token, each of which constitutes a positive selection, you may use any combination of tokens from the non-IE browsers plus the token "IE".</p>
<p>To select a specific IE only one token in the dr:select attribute is allowed, because it is directly used in constructing a Conditional Comment (CC). These are constructed on the fly only if the current browser is actually an IE. Any valid CC expression is allowed, so you can specify for example dr:select="lte IE 7" (positive selection) or dr:select="!IE 6" (negative selection). To clarify, a positive CC selection will allow only the IE's specified to read the CSS, and a negative CC will exclude them from seeing it. The best, you don't need anymore to include Microsoft proprietary CC's for selecting CSS in your HTML!</p>
<p>Link and style elements without a dr:select attribute are considered common stylesheets which every browser will see. They will remain unchanged, as any other HTML element. Only the dr:select attributes will be nullified.
</p></blockquote>
<p>You could do this when JavaScript isn't enabled for example.... although I am not sure how practical it actually is :)</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/browser-detection-with-xslt/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Web Resources He Uses</title>
		<link>http://ajaxian.com/archives/web-resources-he-uses</link>
		<comments>http://ajaxian.com/archives/web-resources-he-uses#comments</comments>
		<pubDate>Mon, 19 Jan 2009 10:27:39 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=5713</guid>
		<description><![CDATA["Ethan" has a really nicely packaged set of web resources that he uses. From JavaScript core libraries, to widgets, to tools, to CSS frameworks, to CSS techniques, to browser compatibility, to typography, to extensions, and much much more. Nicely done.]]></description>
			<content:encoded><![CDATA[<p><a href="http://elementiks.com/web_resources.php"><img src="http://ajaxian.com/wp-content/uploads/webresources.png" alt="" title="web resources" width="500" height="325" class="alignnone size-full wp-image-5714" /></a></p>
<p>"Ethan" has a really nicely packaged set of <a href="http://elementiks.com/web_resources.php">web resources</a> that he uses.</p>
<p>From JavaScript core libraries, to widgets, to tools, to CSS frameworks, to CSS techniques, to browser compatibility, to typography, to extensions, and much much more. Nicely done.</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/web-resources-he-uses/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Forcing a UI redraw from JavaScript</title>
		<link>http://ajaxian.com/archives/forcing-a-ui-redraw-from-javascript</link>
		<comments>http://ajaxian.com/archives/forcing-a-ui-redraw-from-javascript#comments</comments>
		<pubDate>Mon, 12 Jan 2009 18:45:33 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=5640</guid>
		<description><![CDATA[Thomas Fuchs has run into those annoying times when a redraw is required to irk the browser into a correct layout, and his weapon of choice is: PLAIN TEXT JAVASCRIPT: &#160; Element.addMethods&#40;&#123; &#160; redraw: function&#40;element&#41;&#123; &#160; &#160; element = $&#40;element&#41;; &#160; &#160; var n = document.createTextNode&#40;' '&#41;; &#160; &#160; element.appendChild&#40;n&#41;; &#160; &#160; &#40;function&#40;&#41;&#123;n.parentNode.removeChild&#40;n&#41;&#125;&#41;.defer&#40;&#41;; &#160; &#160; <a href="http://ajaxian.com/archives/forcing-a-ui-redraw-from-javascript">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p>Thomas Fuchs has run into those annoying times when a redraw is required to irk the browser into a correct layout, and his weapon of choice is:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-42');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-42">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">Element.<span style="color: #006600;">addMethods</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; redraw: <span style="color: #003366; font-weight: bold;">function</span><span style="color:#006600; font-weight:bold;">&#40;</span>element<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; element = $<span style="color:#006600; font-weight:bold;">&#40;</span>element<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> n = document.<span style="color: #006600;">createTextNode</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">' '</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; element.<span style="color: #006600;">appendChild</span><span style="color:#006600; font-weight:bold;">&#40;</span>n<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span>n.<span style="color: #006600;">parentNode</span>.<span style="color: #006600;">removeChild</span><span style="color:#006600; font-weight:bold;">&#40;</span>n<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #006600;">defer</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> element;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>This is an update to the Script.aculo.us <code>forceRerendering</code> so it will probably be in Scripty 2? :)</p>
<p>Sebastian of Qooxdoo had a similar technique:</p>
<blockquote><p>
You may also use some kind of addClass/removeClass combo. That would result into the same effect but without creating unused DOM elements. We use this method in qooxdoo and it works well.
</p></blockquote>
<p>Do you run into these issues?</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/forcing-a-ui-redraw-from-javascript/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Guid0: JavaScript GUIDs</title>
		<link>http://ajaxian.com/archives/guid0-javascript-guids</link>
		<comments>http://ajaxian.com/archives/guid0-javascript-guids#comments</comments>
		<pubDate>Fri, 14 Nov 2008 11:47:33 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Library]]></category>
		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=5061</guid>
		<description><![CDATA[Our own Michael Mahemoff is at it again, creating a simple little GUID generator called Guid0: Guid0 is a GUID library for Javascript. Okay, it doesn't yet do official, bona fide, 128-bit, GUIDs yet, mainly for API design reasons. But this is a library you might find useful if you want to generate a unique <a href="http://ajaxian.com/archives/guid0-javascript-guids">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p>Our own Michael Mahemoff is at it again, creating a simple little <a href="http://softwareas.com/guid0-a-javascript-guid-generator">GUID generator called Guid0</a>:</p>
<blockquote><p>
Guid0 is a GUID library for Javascript. Okay, it doesn't yet do official, bona fide, 128-bit, GUIDs yet, mainly for API design reasons. But this is a library you might find useful if you want to generate a unique ID in your Ajax app.</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-44');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-44">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">// simple</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">guid = <span style="color: #003366; font-weight: bold;">new</span> Guid<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> newguid = guid.<span style="color: #006600;">generate</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">// options</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">guid = <span style="color: #003366; font-weight: bold;">new</span> Guid<span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; chars: Guid.<span style="color: #006600;">constants</span>.<span style="color: #006600;">base85</span>,&nbsp; <span style="color: #009900; font-style: italic;">// or you could say &quot;abc&quot; if you only wanted those chars to appear</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; epoch: <span style="color: #3366CC;">"June 1, 2003"</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; counterSequenceLength: <span style="color:#800000;">2</span>, <span style="color: #009900; font-style: italic;">// a counter field appended to the end</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; randomSequenceLength: <span style="color:#800000;">2</span> <span style="color: #009900; font-style: italic;">// a random field appended to the end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>He is working on 128-bit support.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/guid0-javascript-guids/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Finding those trailing commas</title>
		<link>http://ajaxian.com/archives/finding-those-trailing-commas</link>
		<comments>http://ajaxian.com/archives/finding-those-trailing-commas#comments</comments>
		<pubDate>Wed, 01 Oct 2008 10:37:59 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[Tip]]></category>
		<category><![CDATA[Utility]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=4649</guid>
		<description><![CDATA[Dan Fabulich got bitten by the "trailing comma" issue one too many times, so he created a script to solve his problem: “How many thousands of developer hours have been lost to random IE bugs like this?” I asked myself. I decided that there had to be a good way to detect this problem in <a href="http://ajaxian.com/archives/finding-those-trailing-commas">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p>Dan Fabulich got bitten by the "trailing comma" issue one too many times, so he created a script to solve his problem:</p>
<blockquote><p>
“How many thousands of developer hours have been lost to random IE bugs like this?” I asked myself. I decided that there had to be a good way to detect this problem in an automated way, without firing up a copy of IE and running a full test suite.</p>
<p>It turns out that these and other syntax errors can be detected automatically from the Windows command line, using the Windows Scripting Host (WSH).  On Windows XP and higher, the command-line tool “cscript.exe” can be used to run JavaScript (ahem, JScript) headlessly (outside of any browser).</p>
<p>Just create a file called “wsh-parser.js” like this:</p>
<div class="igBar"><a href="javascript:showCodeTxt('javascript-46');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">JAVASCRIPT:</span>
<div id="javascript-46">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> fso = <span style="color: #003366; font-weight: bold;">new</span> ActiveXObject<span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color: #3366CC;">"Scripting.FileSystemObject"</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">function</span> parse<span style="color:#006600; font-weight:bold;">&#40;</span>fname<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> file = fso.<span style="color: #006600;">OpenTextFile</span><span style="color:#006600; font-weight:bold;">&#40;</span> fname, <span style="color:#800000;">1</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; ret = file.<span style="color: #006600;">ReadAll</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; file.<span style="color: #006600;">Close</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">try</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">eval</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"(function(){<span style="color: #000099; font-weight: bold;">\n</span>"</span>+ret+<span style="color: #3366CC;">"<span style="color: #000099; font-weight: bold;">\n</span>});"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color: #000066; font-weight: bold;">catch</span> <span style="color:#006600; font-weight:bold;">&#40;</span>e<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; WScript.<span style="color: #006600;">Echo</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"Syntax error parsing "</span> + fname<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; WScript.<span style="color: #006600;">Echo</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"&nbsp; "</span> + e.<span style="color: #006600;">message</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">function</span> findJavaScript<span style="color:#006600; font-weight:bold;">&#40;</span>folder<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">for</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> fc = <span style="color: #003366; font-weight: bold;">new</span> Enumerator<span style="color:#006600; font-weight:bold;">&#40;</span>folder.<span style="color: #006600;">files</span><span style="color:#006600; font-weight:bold;">&#41;</span>; !fc.<span style="color: #006600;">atEnd</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; fc.<span style="color: #006600;">moveNext</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> file=fc.<span style="color: #006600;">item</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #0066FF;">/.<span style="color: #006600;">js</span>$/</span>.<span style="color: #006600;">test</span><span style="color:#006600; font-weight:bold;">&#40;</span>file.<span style="color: #006600;">Name</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; parse<span style="color:#006600; font-weight:bold;">&#40;</span>file<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">for</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> fc = <span style="color: #003366; font-weight: bold;">new</span> Enumerator<span style="color:#006600; font-weight:bold;">&#40;</span>folder.<span style="color: #006600;">subfolders</span><span style="color:#006600; font-weight:bold;">&#41;</span>; !fc.<span style="color: #006600;">atEnd</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; fc.<span style="color: #006600;">moveNext</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> subfolder = fc.<span style="color: #006600;">item</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>subfolder.<span style="color: #006600;">Name</span> == <span style="color: #3366CC;">".svn"</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #000066; font-weight: bold;">continue</span>; <span style="color: #009900; font-style: italic;">// ignore .svn folders</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; findJavaScript<span style="color:#006600; font-weight:bold;">&#40;</span>subfolder<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> rootPath = <span style="color: #3366CC;">"src/main/javascript"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> rootFolder = fso.<span style="color: #006600;">GetFolder</span><span style="color:#006600; font-weight:bold;">&#40;</span>rootPath<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">findJavaScript<span style="color:#006600; font-weight:bold;">&#40;</span>rootFolder<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
</blockquote>
<p>Other tools will help you hunt this down too, and I am sure some of you have Perl/Ruby/Python one liners to do the same ;)</p>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/finding-those-trailing-commas/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maintaining Browser Specific CSS</title>
		<link>http://ajaxian.com/archives/maintaining-css</link>
		<comments>http://ajaxian.com/archives/maintaining-css#comments</comments>
		<pubDate>Fri, 26 Sep 2008 11:35:46 +0000</pubDate>
		<dc:creator>Dion Almaer</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://ajaxian.com/?p=4612</guid>
		<description><![CDATA[Nick Cairns saw our post on conditional CSS for browsers and followed up discussing how he handles maintaining IE specific CSS selectors: We keep our IE related styling right below the common (standards-based) declarations. BUT, we DON’T use hacks. Underscore hacks, * hacks, and all of those things that we all gave up with the <a href="http://ajaxian.com/archives/maintaining-css">Read the rest...</a>]]></description>
			<content:encoded><![CDATA[<p>Nick Cairns saw <a href="http://ajaxian.com/archives/conditional-css-inline-browser-specific-css">our post on conditional CSS for browsers</a> and followed up <a href="http://blog.niccai.com/post/51688182/maintainable-css-using-ie-specific-css-selectors">discussing how he handles maintaining IE specific CSS selectors</a>:</p>
<blockquote><p>
We keep our IE related styling right below the common (standards-based) declarations.  BUT, we DON’T use hacks.  Underscore hacks, * hacks, and all of those things that we all gave up with the birth of IE7 should remain dead and buried.  Instead, we’re going to use IE’s conditional commenting to create IE specific CSS selectors.  We do this by adding a conditional comment block as the outer most wrapper in our html template (ie. the first tag inside the <body>).</p>
<div class="igBar"><a href="javascript:showCodeTxt('html-49');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">HTML:</span>
<div id="html-49">
<div class="html">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body&gt;</span></span><span style="color: #009900;"><a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">&lt;body&gt;</span></a></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!--[if IE 7]&gt;</span></span><span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"body1"</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"IE IE7 IE67"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;</span></a>!<span style="color:#006600; font-weight:bold;">&#91;</span>endif<span style="color:#006600; font-weight:bold;">&#93;</span>--<span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!--[if IE 6]&gt;</span></span><span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"body1"</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"IE IE6 IE56 IE67"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;</span></a>!<span style="color:#006600; font-weight:bold;">&#91;</span>endif<span style="color:#006600; font-weight:bold;">&#93;</span>--<span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!--[if IE 5]&gt;</span></span><span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"body1"</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"IE IE5 IE56"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;</span></a>!<span style="color:#006600; font-weight:bold;">&#91;</span>endif<span style="color:#006600; font-weight:bold;">&#93;</span>--<span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!--[if !IE]&gt;</span></span>--&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"body1"</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"W3C"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!--&lt;![endif]--&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* THE REST OF YOUR HTML GOES HERE */</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span>&nbsp; &nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body&gt;</span></span>&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>Now, in this sample, we do have support for older legacy versions of IE, so you could always reduce the number of conditions if your project doesn’t need this level of support. And, you could also easily extend it to include IE8, or to do minus versioning such as IE8-.</p>
<p>With this conditional block in place, it becomes quite easy to place IE only style declarations right below their standards-based counterparts. As an example:</p>
<div class="igBar"><a href="javascript:showCodeTxt('css-50');">PLAIN TEXT</a></div>
<div class="syntax_hilite"><span style="color:#000000; font-weight:bold;">CSS:</span>
<div id="css-50">
<div class="css">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #cc00cc;">#header <span style="color:#006600; font-weight:bold;">&#123;</span></span> <span style="color: #000000; font-weight: bold;">overflow</span>: <span style="color: #993333;">hidden</span>; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #6666ff;">.IE </span><span style="color: #cc00cc;">#header <span style="color:#006600; font-weight:bold;">&#123;</span></span> zoom: <span style="color:#800000;">1</span>; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="color:#000000; font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://ajaxian.com/archives/maintaining-css/feed</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
	</channel>
</rss>

