<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/rss2full.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><!-- generator="wordpress/2.3.2" --><rss 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/" version="2.0">

<channel>
	<title>Paul Irish</title>
	<link>http://paulirish.com</link>
	<description>dot com</description>
	<pubDate>Sat, 15 Nov 2008 00:08:10 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.2</generator>
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/paul-irish" type="application/rss+xml" /><item>
		<title>Conditional stylesheets vs CSS hacks? Answer: Neither!</title>
		<link>http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/</link>
		<comments>http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/#comments</comments>
		<pubDate>Mon, 20 Oct 2008 22:46:13 +0000</pubDate>
		<dc:creator>Paul Irish</dc:creator>
		
		<category><![CDATA[front-end development]]></category>

		<guid isPermaLink="false">http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/</guid>
		<description><![CDATA[From what I’ve seen a good number of developers these days are split between conditional stylesheets and css hacks. 
You’re used to seeing this:

  &#60;link rel=&#34;stylesheet&#34; type=&#34;text/css&#34; media=&#34;screen&#34; href=&#34;css/style.css&#34; /&#62;
  &#60;!--[if IE 7]&#62;
&#60;link rel=&#34;stylesheet&#34; type=&#34;text/css&#34; media=&#34;screen&#34; href=&#34;css/ie7.css&#34;  /&#62;&#60; !&#91;endif&#93;--&#62;
  &#60;!--[if IE 6]&#62;
&#60;link rel=&#34;stylesheet&#34; type=&#34;text/css&#34; media=&#34;screen&#34; href=&#34;css/ie6.css&#34;  /&#62;&#60; !&#91;endif&#93;--&#62;

But probably also [...]]]></description>
			<content:encoded><![CDATA[<p>From what I’ve seen a good number of developers these days are split between conditional stylesheets and css hacks. </p>
<p>You’re used to seeing this:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict">  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;link</span> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">media</span>=<span style="color: #ff0000;">&quot;screen&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;css/style.css&quot;</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!--[if IE 7]&gt;</span>
</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;link</span> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">media</span>=<span style="color: #ff0000;">&quot;screen&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;css/ie7.css&quot;</span>  /<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;</span> !<span style="color: #66cc66;">&#91;</span>endif<span style="color: #66cc66;">&#93;</span>--<span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!--[if IE 6]&gt;</span>
</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;link</span> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">media</span>=<span style="color: #ff0000;">&quot;screen&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;css/ie6.css&quot;</span>  /<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;</span> !<span style="color: #66cc66;">&#91;</span>endif<span style="color: #66cc66;">&#93;</span>--<span style="color: #000000; font-weight: bold;">&gt;</span></span></pre></div></div>

<p>But probably also plenty of this:</p>

<div class="wp_syntax"><div class="code"><pre class="css">div<span style="color: #6666ff;">.infoBox</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #000000; font-weight: bold;">float</span>: <span style="color: #000000; font-weight: bold;">left</span>; <span style="color: #000000; font-weight: bold;">padding-right</span>: <span style="color: #933;">10px</span>; _padding-<span style="color: #000000; font-weight: bold;">right</span>: <span style="color: #933;">5px</span>; <span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>CSS hacks to target specific browsers stay where the rest of your styles are, but they certainly don’t validate. For sometime now, the standards community has rallied around conditional stylesheets as a solution to the validation problem.</p>
<p>There are a few problems with it though:</p>
<ul>
<li>Conditional stylesheets mean 1 or 2 additional HTTP requests to download</li>
<li>As they are in the the &lt;head&gt;, the rendering of the page waits until they're totally loaded.</li>
<li><small> Also - Yahoo's internal coding best practices do not recommend conditional stylesheets</small></li>
<li>It can separate a single CSS rule into multiple files. I’ve spent a lot of time wondering “Where the eff is that rule coming from!?” when it turned out to be tucked away in a conditional stylesheet.</li>
</ul>
<p>Here’s my proposed solution:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict"> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;body</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;body &lt;!--[if IE ]&gt;</span>ie<span style="color: #009900;">&lt; ![endif]--&gt;</span> <span style="color: #009900;">&lt;!--[if lte IE 6]&gt;</span>ie6<span style="color: #009900;">&lt; ![endif]--&gt;</span> <span style="color: #009900;">&lt;!--[if IE 7]&gt;</span>ie7<span style="color: #009900;">&lt; ![endif]--&gt;</span> <span style="color: #009900;">&lt;!--[if IE 8]&gt;</span>ie8<span style="color: #009900;">&lt; ![endif]--&gt;</span> &quot;&gt;</span></pre></div></div>

<p>Using the same conditional comments, we’re just conditionally adding an extra class onto the body tag. This allows us to keep our browser-specific css in the same file:</p>

<div class="wp_syntax"><div class="code"><pre class="css"> div<span style="color: #6666ff;">.foo</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span>: <span style="color: #993333;">inherit</span>;<span style="color: #66cc66;">&#125;</span>
<span style="color: #6666ff;">.ie</span> div<span style="color: #6666ff;">.foo</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span>: <span style="color: #cc00cc;">#ff8000</span>; <span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Plus it totally validates and works in all browsers.<br />
(Hat tip to <a href="http://www.paulhammond.org/2008/10/conditional/">Paul Hammond</a> and <a href="http://blog.amodernfable.com/">Adam McIntyre</a> for being s-m-r-t.)</p>
<p><strong>Update:</strong> Sadly the syntax  I propose doesn't work reliably. While it works fine if you query <code>document.body.className</code> <i>before<i> the DOM has finished loading (like in a document.write()), it doesn't work once the DOM has successfully finished loading. Sigh. </p>
<p>Here is the most concise replacement code that works:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict"><span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!--[if lt IE 7 ]&gt;</span>
</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;body</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;ie6&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;</span>!<span style="color: #66cc66;">&#91;</span>endif<span style="color: #66cc66;">&#93;</span>--<span style="color: #000000; font-weight: bold;">&gt;</span></span> <span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!--[if IE 7 ]&gt;</span>
</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;body</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;ie7&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;</span>!<span style="color: #66cc66;">&#91;</span>endif<span style="color: #66cc66;">&#93;</span>--<span style="color: #000000; font-weight: bold;">&gt;</span></span> <span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!--[if IE 8 ]&gt;</span>
</span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;body</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;ie8&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;</span>!<span style="color: #66cc66;">&#91;</span>endif<span style="color: #66cc66;">&#93;</span>--<span style="color: #000000; font-weight: bold;">&gt;</span></span> <span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!--[if !IE]&gt;</span>
</span>--&gt; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;body&gt;</span></span><span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!--&lt;![endif]--&gt;</span></span></pre></div></div>

<p>It still validates and works in FF2,FF3,IE6,IE7,Chrome,Safari3.</p>
]]></content:encoded>
			<wfw:commentRss>http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Release: infinite-scroll.com! (w/ jquery and wordpress plugins)</title>
		<link>http://paulirish.com/2008/release-infinite-scroll-com-jquery-and-wordpress-plugins/</link>
		<comments>http://paulirish.com/2008/release-infinite-scroll-com-jquery-and-wordpress-plugins/#comments</comments>
		<pubDate>Thu, 25 Sep 2008 23:31:30 +0000</pubDate>
		<dc:creator>Paul Irish</dc:creator>
		
		<category><![CDATA[front-end development]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://paulirish.com/2008/release-infinite-scrollcom-w-jquery-and-wordpress-plugins/</guid>
		<description><![CDATA[Today I'm releasing www.infinite-scroll.com. Essentially infinite scroll is using ajax to pre-fetch content from a subsequent page and add it directly to the user’s current page. If you have no idea what I'm talking about, you should scroll down to the bottom of aurgasm.us, roflcon.org, or blog.molecular.com.

There is a full  design pattern explanation describing [...]]]></description>
			<content:encoded><![CDATA[<p>Today I'm releasing <a href="http://www.infinite-scroll.com/">www.infinite-scroll.com</a>. Essentially infinite scroll is using ajax to pre-fetch content from a subsequent page and add it directly to the user’s current page. If you have no idea what I'm talking about, you should scroll down to the bottom of <a href="http://aurgasm.us">aurgasm.us</a>, <a href="http://roflcon.org">roflcon.org</a>, or <a href="http://blog.molecular.com">blog.molecular.com</a>.</p>
<p><a href='http://www.infinite-scroll.com/' title='www.infinite-scroll.com'><img src='http://paulirish.com/wp-content/uploads/2008/09/infscrcom-screenshot.jpg' align="right" width="275"/></a>
<p>There is a full  <strong>design pattern explanation</strong> describing when to use it, and considerations to think about when implementing. I also wrote a <strong>history of infinite scroll</strong>, to cover the history of this somewhat new ajax-enabled interaction technique.</p>
<p>But most importantly, there are two software releases in here:</p>
<h3>The Infinite Scroll Wordpress plugin</h3>
<p> Enable your wordpress blog with infinite scroll functionality without knowing any javascript. You just need to know css selectors. And no theme php changes should be required to use.</p>
<h3>The Infinite Scroll jQuery plugin</h3>
<p> Enable anything! Obviously this is for javascript developers only, but it should give you enough flexibility to utilize in your own application. </p>
<h4>Check it all out at <a href="http://www.infinite-scroll.com">www.infinite-scroll.com</a>.</h4>
<p><br/><br/><br/><br />
Since this is a development-focused blog, you may ask...</p>
<h3>How is it done?</h3>
<p>There is a little known feature in the <a href="http://docs.jquery.com/Ajax/load#urldatacallback"><code>.load()</code></a> method that lets you specify the CSS selector of the html you want to include. jQuery will load in any local URL, then parse the html and grab only the elements you've defined with your selector. This allows for some pretty fun shit: client-side transclusions (a la <a href="http://ajaxian.com/archives/purple-include-transclusions-you-know-you-want-them">purple include</a>) ; and some really kickass shit when you combo it with a <a href="http://developer.yahoo.com/javascript/howto-proxy.html">local php proxy</a>.</p>
<p>This is really the meat of the code:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #009900; font-style: italic;">// load all post divs from page 2 into an off-DOM div</span>
$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'&lt;div/&gt;'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">load</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'/page/2/ #content div.post'</span>,<span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span> 
    $<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">appendTo</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#content'</span><span style="color: #66cc66;">&#41;</span>;    <span style="color: #009900; font-style: italic;">// once they're loaded, append them to our content area</span>
<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>So the infinite scroll plugin basically leverages that <code>load()</code> method at its core. It's basically scraping your existing page structure, which means <strong>you don't need to code any custom backend stuff to enable this functionality!</strong> Booyah, right?</p>
<p>The rest of <a href="http://code.paulirish.com/wp-infinite-scroll/jquery.infinitescroll.js">the code</a> maintains the status of the ajax call, dies when it finishes going through your pages, and show/hides the loading notification. Please take a look and let me know what you think!</p>
]]></content:encoded>
			<wfw:commentRss>http://paulirish.com/2008/release-infinite-scroll-com-jquery-and-wordpress-plugins/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Sequentially chain your callbacks in jQuery - Two ways</title>
		<link>http://paulirish.com/2008/sequentially-chain-your-callbacks-in-jquery-two-ways/</link>
		<comments>http://paulirish.com/2008/sequentially-chain-your-callbacks-in-jquery-two-ways/#comments</comments>
		<pubDate>Fri, 22 Aug 2008 20:39:09 +0000</pubDate>
		<dc:creator>Paul Irish</dc:creator>
		
		<category><![CDATA[javascript]]></category>

		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://paulirish.com/2008/sequentially-chain-your-callbacks-in-jquery-two-ways/</guid>
		<description><![CDATA[I had a challenge to get four divs to fade in sequentially. 
Writing this out the long way is not really my favorite:

$&#40;&#34;#vehicle1&#34;&#41;.fadeIn&#40;&#34;slow&#34;, function&#40;&#41;&#123;
  $&#40;&#34;#vehicle2&#34;&#41;.fadeIn&#40;&#34;slow&#34;, function&#40;&#41;&#123;
    $&#40;&#34;#vehicle3&#34;&#41;.fadeIn&#40;&#34;slow&#34;, function&#40;&#41;&#123;
      $&#40;&#34;#vehicle4&#34;&#41;.fadeIn&#40;&#34;slow&#34;&#41;;
    &#125;&#41;;
  &#125;&#41;;
&#125;&#41;;

Ewwww. right?
After some conversation in the #jQuery IRC channel, I present two [...]]]></description>
			<content:encoded><![CDATA[<p>I had a challenge to get <strong>four divs to fade in sequentially</strong>. </p>
<p>Writing this out the long way is not really my favorite:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript">$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;#vehicle1&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">fadeIn</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;slow&quot;</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
  $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;#vehicle2&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">fadeIn</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;slow&quot;</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
    $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;#vehicle3&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">fadeIn</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;slow&quot;</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
      $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;#vehicle4&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">fadeIn</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;slow&quot;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>Ewwww. right?</p>
<p>After some conversation in the #jQuery IRC channel, I present two classier ways of accomplishing the same thing:</p>
<h4>Self-executing callback chaining</h4>

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> showVehicle<span style="color: #66cc66;">&#40;</span>elem<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
  elem.<span style="color: #006600;">fadeIn</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'slow'</span>,<span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
    $<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">next</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">length</span> &amp;&amp; showVehicle<span style="color: #66cc66;">&#40;</span>$<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">next</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; 
  <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#40;</span> $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;div.vehicle:first&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<h4>Custom event triggering <small>(via: ajpiano)</small></h4>

<div class="wp_syntax"><div class="code"><pre class="javascript">$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'div.vehicle'</span><span style="color: #66cc66;">&#41;</span>
  .<span style="color: #006600;">bind</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'showVehicle'</span>,<span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>$<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">fadeIn</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'slow'</span>,<span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span> 
    $<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">next</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">length</span> &amp;&amp; $<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">next</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">trigger</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;showVehicle&quot;</span><span style="color: #66cc66;">&#41;</span>; 
  <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
  .<span style="color: #006600;">eq</span><span style="color: #66cc66;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #66cc66;">&#41;</span>
    .<span style="color: #006600;">trigger</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'showVehicle'</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://paulirish.com/2008/sequentially-chain-your-callbacks-in-jquery-two-ways/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Best of BusinessWeek’s Design Award Winners, 2008</title>
		<link>http://paulirish.com/2008/best-of-businessweeks-design-award-winners-2008/</link>
		<comments>http://paulirish.com/2008/best-of-businessweeks-design-award-winners-2008/#comments</comments>
		<pubDate>Mon, 11 Aug 2008 01:31:33 +0000</pubDate>
		<dc:creator>Paul Irish</dc:creator>
		
		<category><![CDATA[hmm!]]></category>

		<guid isPermaLink="false">http://paulirish.com/2008/best-of-businessweeks-design-award-winners-2008/</guid>
		<description><![CDATA[There were over 200 winners of BusinessWeek's Design Awards. Here are the best.

The Muwi innovation lawn mower takes grass cuttings and turns them into something fun.  The blocks can become balls for children to play with or be combined to make a chair or anything else you can think of.


Adaptable to different spaces, terrains [...]]]></description>
			<content:encoded><![CDATA[<p>There were over 200 winners of <a href="http://www.businessweek.com/magazine/toc/08_30/B4093idea_best_product_design_awards.htm">BusinessWeek's Design Awards</a>. Here are the best.</p>
<p><a href="http://images.businessweek.com/ss/08/07/0717_idea_winners/191.htm"><img src="http://images.businessweek.com/ss/08/07/0717_idea_winners/image/b_muwi.jpg"/></a></p>
<blockquote><p>The Muwi innovation lawn mower takes grass cuttings and turns them into something fun.  The blocks can become balls for children to play with or be combined to make a chair or anything else you can think of.
</p></blockquote>
<p><a href="http://images.businessweek.com/ss/08/07/0717_idea_winners/188.htm"><img src="http://images.businessweek.com/ss/08/07/0717_idea_winners/image/b_interactive_lounge.jpg"/></a></p>
<blockquote><p>Adaptable to different spaces, terrains and architectural styles, the Interactive Lounge was designed to provide relaxation and interactivity with the surrounding environment.
</p></blockquote>
<p><a href="http://images.businessweek.com/ss/08/07/0717_idea_winners/181.htm"><img src="http://images.businessweek.com/ss/08/07/0717_idea_winners/image/s_trace_of_time.jpg"/></a></p>
<blockquote><p>The face of the clock is made of laminated whiteboard. Messages are erased by means of the integrated eraser.
</p></blockquote>
<p><a href="http://images.businessweek.com/ss/08/07/0717_idea_winners/166.htm"><img src="http://images.businessweek.com/ss/08/07/0717_idea_winners/image/g_flyingstick.jpg"/></a></p>
<blockquote><p>With FlyingStick, you don’t need any countdowns or goofy sayings. FlyingStick takes the picture by itself when it is in the air. Since no one knows when the shutter is released, you will get a more natural picture.
</p></blockquote>
<p><a href="http://images.businessweek.com/ss/08/07/0717_idea_winners/155.htm"><img src="http://images.businessweek.com/ss/08/07/0717_idea_winners/image/g_senz_xl_storm_umbrel.jpg"/></a></p>
<blockquote><p>Due to its asymmetric design, the SENZ XL storm umbrella automatically finds the best position in the wind, making it comfortable and easy to use, even in strong gusts.
</p></blockquote>
<p><a href="http://images.businessweek.com/ss/08/07/0717_idea_winners/145.htm"><img src="http://images.businessweek.com/ss/08/07/0717_idea_winners/image/b_4in1pharmacytool_web.jpg"/></a></p>
<blockquote><p>The 4-in-1 Pharmacy Tool is a portable handheld device designed to assist busy pharmacists with the repetitive tasks of opening medicine bottles and counting pills to fill patient prescriptions.
</p></blockquote>
<p><a href="http://images.businessweek.com/ss/08/07/0717_idea_winners/130.htm"><img src="http://images.businessweek.com/ss/08/07/0717_idea_winners/image/b_form_6_web.jpg"/></a></p>
<blockquote><p>Form 6 is the only rechargeable vibrating massager that is also water-resistant, making it suitable for use in the shower.
</p></blockquote>
<p><a href="http://images.businessweek.com/ss/08/07/0717_idea_winners/125.htm"><img src="http://images.businessweek.com/ss/08/07/0717_idea_winners/image/s_siliconebottle.jpg"/></a></p>
<blockquote><p>This design has solved all of those problems with a squishable, leakproof, easy to fill and easy to clean way to store and dispense liquids and gels during travel.
</p></blockquote>
<p><a href="http://images.businessweek.com/ss/08/07/0717_idea_winners/92.htm"><img src="http://images.businessweek.com/ss/08/07/0717_idea_winners/image/s_0391_super_bossa_comp.jpg"/></a></p>
<blockquote><p>Users can move the reflector up or down, changing the light from direct to indirect.
</p></blockquote>
<p><a href="http://images.businessweek.com/ss/08/07/0717_idea_winners/72.htm"><img src="http://images.businessweek.com/ss/08/07/0717_idea_winners/image/s_sombrero.jpg"/></a></p>
<blockquote><p>Designed to be mounted to the underside of any work surface, this sombrero-shaped spool reins in unruly or excess cable by winding it around its core and firmly anchoring the exiting cable into any of the three V-shaped notches.
</p></blockquote>
<p><a href="http://images.businessweek.com/ss/08/07/0717_idea_winners/62.htm"><img src="http://images.businessweek.com/ss/08/07/0717_idea_winners/image/b_lite2go_print.jpg"/></a></p>
<blockquote><p>The packaging becomes the shade for the energy-saving light bulb and electric cord contained within
</p></blockquote>
<p><a href="http://images.businessweek.com/ss/08/07/0717_idea_winners/12.htm"><img src="http://images.businessweek.com/ss/08/07/0717_idea_winners/image/s_0346_ziplux_04.jpg"/></a></p>
<blockquote><p>The light source is positioned at the totem’s base and transmitted to the top by means of fiber optic cables. Ziplux allows angle control so that nearly 100% of the light beams can be focused at desired locations and glare is reduced. A single light source can illuminate different spots, thus enabling lighting in dark street areas and helping to revitalize public spaces.
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://paulirish.com/2008/best-of-businessweeks-design-award-winners-2008/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The two CSS Selector bugs in IE6</title>
		<link>http://paulirish.com/2008/the-two-css-selector-bugs-in-ie6/</link>
		<comments>http://paulirish.com/2008/the-two-css-selector-bugs-in-ie6/#comments</comments>
		<pubDate>Tue, 05 Aug 2008 17:53:59 +0000</pubDate>
		<dc:creator>Paul Irish</dc:creator>
		
		<category><![CDATA[front-end development]]></category>

		<guid isPermaLink="false">http://paulirish.com/2008/the-two-css-selector-bugs-in-ie6/</guid>
		<description><![CDATA[Internet Explorer 6's CSS selector support is a far cry from every other A-Grade browser. It doesn't handle attribute tags, adjacent or child selectors, or the :first-child psuedo-selector. And yes, it sucks. We deal with it.
But beyond selectors not being implemented, there are two BUGS when it comes to selectors in IE6:

The multiple class bug
When [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://msdn.microsoft.com/en-us/library/cc351024(VS.85).aspx">Internet Explorer 6's CSS selector support</a> is a far cry from every other <a href="http://developer.yahoo.com/yui/articles/gbs/">A-Grade browser</a>. It doesn't handle attribute tags, adjacent or child selectors, or the <code>:first-child</code> psuedo-selector. And yes, it sucks. We deal with it.</p>
<p>But beyond selectors not being implemented, there are <strong>two BUGS </strong>when it comes to selectors in IE6:</p>
<dl>
<dt>The multiple class bug</dt>
<dd>When you define rules like:</p>

<div class="wp_syntax"><div class="code"><pre class="css">p<span style="color: #6666ff;">.disclosure</span><span style="color: #6666ff;">.warning</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #000000; font-weight: bold;">text-align</span>: <span style="color: #993333;">center</span>; <span style="color: #000000; font-weight: bold;">color</span>: <span style="color: #993333;">red</span>; <span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Most browsers will apply this to any P tags with both the class <em>disclosure </em>and <em>warning</em>. <strong>IE6, however, will only apply this to P tags with the last class mentioned</strong>; in this case, P tags with the class warning. so IE6 pretends like you wrote:</p>

<div class="wp_syntax"><div class="code"><pre class="css">p<span style="color: #6666ff;">.warning</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #000000; font-weight: bold;">text-align</span>: <span style="color: #993333;">center</span>; <span style="color: #000000; font-weight: bold;">color</span>: <span style="color: #993333;">red</span>; <span style="color: #66cc66;">&#125;</span> <span style="color: #808080; font-style: italic;">/* no .disclosure */</span></pre></div></div>

<p>Workarounds are typically not hard, but staying aware of this fact will save you time debugging.</dd>
<dt>The ID-class bug</dt>
<dd>When you define a block like:</p>

<div class="wp_syntax"><div class="code"><pre class="css"><span style="color: #cc00cc;">#tooltip</span><span style="color: #6666ff;">.red</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span>: <span style="color: #993333;">white</span>; <span style="color: #000000; font-weight: bold;">color</span>: <span style="color: #993333;">red</span>; <span style="color: #66cc66;">&#125;</span>
<span style="color: #cc00cc;">#tooltip</span><span style="color: #6666ff;">.yellow</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span>: <span style="color: #000000; font-weight: bold;">black</span>; <span style="color: #000000; font-weight: bold;">color</span>: <span style="color: #993333;">red</span>; <span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>IE will ignore the the second rule. So even if you have a</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;tooltip&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;yellow&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>I'm on a black background in yellow text!<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span></pre></div></div>

<p>, IE will not apply the CSS styles you had defined for it. If you have laid our rules for the same ID but different classes, it will ignore all CSS rules defined after the first one. (Your red tooltip will be fine).</p>
<h4>Solutions:</h4>
<ul>
<li>Don't let the #id.class combo be the last selector: Multiple selectors of this type <code>#tooltip.yellow div</code> will be fine. </li>
<li>Move the class to a parent container: <code>div.yellow #tooltip</code> will not mess up anything.</li>
<li>Make your classes be superspecific and dont use an ID in your selector: <code>div.yellowtooltip</code>. You'll have to repeat yourself with duplicate CSS definitions, but you can thank IE6 for making your day miserable, yet again. :)</li>
</ul>
</dd>
</dl>
]]></content:encoded>
			<wfw:commentRss>http://paulirish.com/2008/the-two-css-selector-bugs-in-ie6/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How To: Speed Up The MacRumorsLive Ajax Refresh</title>
		<link>http://paulirish.com/2008/how-to-speed-up-the-macrumorslive-ajax-refresh/</link>
		<comments>http://paulirish.com/2008/how-to-speed-up-the-macrumorslive-ajax-refresh/#comments</comments>
		<pubDate>Mon, 09 Jun 2008 15:16:55 +0000</pubDate>
		<dc:creator>Paul Irish</dc:creator>
		
		<category><![CDATA[hacks]]></category>

		<guid isPermaLink="false">http://paulirish.com/2008/how-to-speed-up-the-macrumorslive-ajax-refresh/</guid>
		<description><![CDATA[By default, MacRumorsLive polls the server for updates only every 60 seconds. I know, I know.. &#60;enter sad puppy face here&#62; If you're like me, you probably want that action with a touch more zip to it! And thus...
To poke the server every 10 seconds for a new update, drop this badboy into the location [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.macrumorslive.com/" title='MacRumorsLive website'><img src='http://paulirish.com/wp-content/uploads/2008/06/title_macrumors1.gif' alt='title_macrumors.gif' align="right"/></a>By default, <a href="http://www.macrumorslive.com/">MacRumorsLive</a> polls the server for <strong>updates only every 60 seconds</strong>. I know, I know.. &lt;enter sad puppy face here&gt; If you're like me, you probably want that action with a touch more zip to it! And thus...</p>
<p>To poke the server <i>every 10 seconds</i> for a new update, <b>drop this badboy into the location bar on your MacRumorsLive tab and hit enter:</b></p>

<div class="wp_syntax"><div class="code"><pre class="javascript">javascript:<span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><span style="color: #003366; font-weight: bold;">var</span> booyah=<span style="color: #CC0000;">10</span>,str=<span style="color: #3366CC;">'ro[0].firstChild.nodeValue'</span>,countdown=<span style="color: #3366CC;">'document.getElementById(&quot;ti&quot;).innerHTML  = (rr-x) + &quot; seconds till next update...&quot;; setTimeout'</span>;rr=booyah;eval<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'d = '</span>+d.<span style="color: #006600;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span>str,booyah<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;eval<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'ppd = '</span>+ppd.<span style="color: #006600;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span>str,booyah<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;eval<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;l = &quot;</span>+l.<span style="color: #006600;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'setTimeout'</span>,countdown<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;x=<span style="color: #CC0000;">5</span>;<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>btw- this doesn't work in IE. Deal with it.</p>
<p><strong>Update (11:41am):</strong> It now has a countdown till next update. <img style="vertical-align: text-bottom" src='http://paulirish.com/wp-content/uploads/2008/06/countdown.PNG' alt='countdown.PNG' /></p>
]]></content:encoded>
			<wfw:commentRss>http://paulirish.com/2008/how-to-speed-up-the-macrumorslive-ajax-refresh/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Bookmarklet: Inject new css rules</title>
		<link>http://paulirish.com/2008/bookmarklet-inject-new-css-rules/</link>
		<comments>http://paulirish.com/2008/bookmarklet-inject-new-css-rules/#comments</comments>
		<pubDate>Thu, 15 May 2008 15:56:22 +0000</pubDate>
		<dc:creator>Paul Irish</dc:creator>
		
		<category><![CDATA[front-end development]]></category>

		<guid isPermaLink="false">http://paulirish.com/2008/bookmarklet-inject-new-css-rules/</guid>
		<description><![CDATA[I love doing as much CSS debugging as I can without hitting reload. (see also: my 'refresh css' bookmarklet)
Firebug can get you a far way in playing with styles. You can edit current css rules and add new styles to a given element, but there is no way to add a brand new rule to [...]]]></description>
			<content:encoded><![CDATA[<p>I love doing as much CSS debugging as I can without hitting reload. (see also: <a href="http://paulirish.com/2008/how-to-iterate-quickly-when-debugging-css/">my 'refresh css' bookmarklet</a>)</p>
<p><img src='http://paulirish.com/wp-content/uploads/2008/05/newcssrule.PNG' alt='newcssrule.PNG' align="right" />Firebug can get you a far way in playing with styles. You can edit current css rules and add new styles to a given element, but there is <strong>no way to add a brand new rule to the page</strong>. UNTIL NOW!!!</p>
<p>Drag this bad boy to your bookmark bar:</p>
<p><big><strong> >>> <a href="javascript:(function(){ var newcss = prompt('New CSS rule:');  var tag = document.createElement('style'); tag.type = %22text/css%22; document.getElementsByTagName('head')[0].appendChild(tag); tag.innerHTML = newcss; })(); ">newcssrule</a> <<< </strong></big></p>
<p>The code is obviously trivial, but it's a helpful button to have around sometimes. Plus you can then edit those rules in firebug immediately.</p>
<p><strong>Update (2008.06.05)</strong>: I should point out this code only works in Firefox (maybe Opera), but for full compatibility, understand the landscape at <a href="http://code.google.com/p/doctype/wiki/ArticleInstallStyles">InstallStyles</a> on Google Doctype.<br />
And this code should get you started:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript">    <span style="color: #003366; font-weight: bold;">function</span> addCSS<span style="color: #66cc66;">&#40;</span>newcss<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>$.<span style="color: #006600;">browser</span>.<span style="color: #006600;">msie</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            document.<span style="color: #006600;">createStyleSheet</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">cssText</span> = newcss;
        <span style="color: #66cc66;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #66cc66;">&#123;</span>
            <span style="color: #003366; font-weight: bold;">var</span> tag = document.<span style="color: #006600;">createElement</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'style'</span><span style="color: #66cc66;">&#41;</span>; tag.<span style="color: #006600;">type</span> = <span style="color: #3366CC;">'text/css'</span>; document.<span style="color: #006600;">getElementsByTagName</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'head'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">appendChild</span><span style="color: #66cc66;">&#40;</span>tag<span style="color: #66cc66;">&#41;</span>; 
            tag<span style="color: #66cc66;">&#91;</span> $.<span style="color: #006600;">browser</span>.<span style="color: #006600;">safari</span> ? <span style="color: #3366CC;">'innerText'</span> : <span style="color: #3366CC;">'innerHTML'</span><span style="color: #66cc66;">&#93;</span> = newcss;    
        <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://paulirish.com/2008/bookmarklet-inject-new-css-rules/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Best practice: Poll instead of a setTimeout hack</title>
		<link>http://paulirish.com/2008/best-practice-poll-instead-of-a-settimeout-hack/</link>
		<comments>http://paulirish.com/2008/best-practice-poll-instead-of-a-settimeout-hack/#comments</comments>
		<pubDate>Tue, 13 May 2008 18:31:20 +0000</pubDate>
		<dc:creator>Paul Irish</dc:creator>
		
		<category><![CDATA[front-end development]]></category>

		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://paulirish.com/2008/best-practice-poll-instead-of-a-settimeout-hack/</guid>
		<description><![CDATA[Very often you'll have events happening asynchronously, but you need to wait until one has completed before you fire the second.
And you may not have the ability of attaching a callback function to the first.
In my less wise days I'd say "Lets just setTimeout it for a couple seconds..." but always felt really dirty about [...]]]></description>
			<content:encoded><![CDATA[<p>Very often you'll have events happening asynchronously, but you need to wait until one has completed before you fire the second.<br />
And you may not have the ability of attaching a callback function to the first.</p>
<p>In my less wise days I'd say "Lets just setTimeout it for a couple seconds..." but always felt really dirty about it. </p>
<p>A classier approach I've used lately is to poll for a change. Here I'm using the <a href="http://code.google.com/p/gmail-greasemonkey/wiki/GmailGreasemonkey10API">gmail greasemonkey API </a>and waiting for it to load in before I start using it:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript">gmonkey.<span style="color: #006600;">load</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;1.0&quot;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #009900; font-style: italic;">// this is a self-executing anonymous function that uses setTimeout to call itself </span>
<span style="color: #009900; font-style: italic;">// at 50ms intervals until the isLoaded variable resolves as true.</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>gmonkey.<span style="color: #006600;">isLoaded</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
    <span style="color: #009900; font-style: italic;">// do stuff i want to do with the API</span>
    gmonkey.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'1.0'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">addNavModule</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'notepad'</span>, <span style="color: #3366CC;">'&lt;iframe src=&quot;http://aaronboodman.com/halfnote/&quot;&gt;&lt;/iframe&gt;'</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #66cc66;">&#123;</span>
    setTimeout<span style="color: #66cc66;">&#40;</span>arguments.<span style="color: #006600;">callee</span>,<span style="color: #CC0000;">50</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>I found myself doing this a lot when loading in multiple external resources and playing with them.. So to generalize the code I wrote <code>executeWhenLoaded()</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #009900; font-style: italic;">// executeWhenLoaded() will be overloaded with as many arguments as i want to check for presence.</span>
<span style="color: #003366; font-weight: bold;">function</span> executeWhenLoaded<span style="color: #66cc66;">&#40;</span>func<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>  
&nbsp;
  <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i = <span style="color: #CC0000;">1</span>; i&lt;arguments.<span style="color: #006600;">length</span>; i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span> <span style="color: #009900; font-style: italic;">// for loop starts at 1 to skip the function argument.</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>! window<span style="color: #66cc66;">&#91;</span> arguments<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
      setTimeout<span style="color: #66cc66;">&#40;</span>arguments.<span style="color: #006600;">callee</span>,<span style="color: #CC0000;">50</span><span style="color: #66cc66;">&#41;</span>;      
      <span style="color: #000066; font-weight: bold;">return</span>;
    <span style="color: #66cc66;">&#125;</span> 
  <span style="color: #66cc66;">&#125;</span>
&nbsp;
  func<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #009900; font-style: italic;">// only reaches here when for loop is satisfied.</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">// and in use:</span>
&nbsp;
executeWhenLoaded<span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span> 
    console.<span style="color: #006600;">log</span><span style="color: #66cc66;">&#40;</span>session.<span style="color: #006600;">data</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>,<span style="color: #3366CC;">'session'</span><span style="color: #66cc66;">&#41;</span>;   <span style="color: #009900; font-style: italic;">// session will return a value when the whatever preceding functionality is done.</span></pre></div></div>

<p>executeWhenLoaded's first argument is the function to call, it can an unlimited number of arguments, which are all strings that reflect objects in the global namespace that have to be present in order to execute that function.</p>
<p><strong>Update:</strong> In the comments, ProggerPete notes that this is not cross-browser compatible.. yet! In IE6, at least, the browser loses the original reference to the arguments object when it cycles through on the arguments.callee call. He offers a fix <a href="http://paulirish.com/2008/best-practice-poll-instead-of-a-settimeout-hack/#comment-17421">below</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://paulirish.com/2008/best-practice-poll-instead-of-a-settimeout-hack/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Quick internationalized sort in javascript</title>
		<link>http://paulirish.com/2008/quick-internationalized-sort-in-javascript/</link>
		<comments>http://paulirish.com/2008/quick-internationalized-sort-in-javascript/#comments</comments>
		<pubDate>Mon, 21 Apr 2008 19:19:27 +0000</pubDate>
		<dc:creator>Paul Irish</dc:creator>
		
		<category><![CDATA[hacks]]></category>

		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://paulirish.com/2008/quick-internationalized-sort-in-javascript/</guid>
		<description><![CDATA[Let's take a list of countries that was originally alphabetized in English, but is now translated to French.

var arr = &#91;&#34;Argentine&#34;, &#34;Australie&#34;, &#34;Autriche&#34;, &#34;Belgique&#34;, &#34;Brésil&#34;, &#34;Canada&#34;, &#34;Chili&#34;, 
&#34;Chine&#34;, &#34;Costa Rica &#34;, &#34;République Tchèque&#34;, &#34;Danemark&#34;, &#34;Équateur&#34;, &#34;El Salvador &#34;, 
&#34;Finlande&#34;, &#34;France&#34;, &#34;Allemagne&#34;, &#34;Guatemala&#34;, &#34;Hong Kong&#34;, &#34;Hongrie&#34;, &#34;Inde&#34;, &#34;Irlande&#34;, 
&#34;Italie&#34;, &#34;Japon&#34;, &#34;Corée du Sud&#34;, &#34;Luxembourg&#34;, &#34;Mexique&#34;, &#34;Pays-Bas&#34;, [...]]]></description>
			<content:encoded><![CDATA[<p>Let's take a list of countries that was originally alphabetized in English, but is now translated to French.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #003366; font-weight: bold;">var</span> arr = <span style="color: #66cc66;">&#91;</span><span style="color: #3366CC;">&quot;Argentine&quot;</span>, <span style="color: #3366CC;">&quot;Australie&quot;</span>, <span style="color: #3366CC;">&quot;Autriche&quot;</span>, <span style="color: #3366CC;">&quot;Belgique&quot;</span>, <span style="color: #3366CC;">&quot;Brésil&quot;</span>, <span style="color: #3366CC;">&quot;Canada&quot;</span>, <span style="color: #3366CC;">&quot;Chili&quot;</span>, 
<span style="color: #3366CC;">&quot;Chine&quot;</span>, <span style="color: #3366CC;">&quot;Costa Rica &quot;</span>, <span style="color: #3366CC;">&quot;République Tchèque&quot;</span>, <span style="color: #3366CC;">&quot;Danemark&quot;</span>, <span style="color: #3366CC;">&quot;Équateur&quot;</span>, <span style="color: #3366CC;">&quot;El Salvador &quot;</span>, 
<span style="color: #3366CC;">&quot;Finlande&quot;</span>, <span style="color: #3366CC;">&quot;France&quot;</span>, <span style="color: #3366CC;">&quot;Allemagne&quot;</span>, <span style="color: #3366CC;">&quot;Guatemala&quot;</span>, <span style="color: #3366CC;">&quot;Hong Kong&quot;</span>, <span style="color: #3366CC;">&quot;Hongrie&quot;</span>, <span style="color: #3366CC;">&quot;Inde&quot;</span>, <span style="color: #3366CC;">&quot;Irlande&quot;</span>, 
<span style="color: #3366CC;">&quot;Italie&quot;</span>, <span style="color: #3366CC;">&quot;Japon&quot;</span>, <span style="color: #3366CC;">&quot;Corée du Sud&quot;</span>, <span style="color: #3366CC;">&quot;Luxembourg&quot;</span>, <span style="color: #3366CC;">&quot;Mexique&quot;</span>, <span style="color: #3366CC;">&quot;Pays-Bas&quot;</span>, <span style="color: #3366CC;">&quot;Nouvelle-Zélande&quot;</span>, 
<span style="color: #3366CC;">&quot;Norvège&quot;</span>, <span style="color: #3366CC;">&quot;Panama&quot;</span>, <span style="color: #3366CC;">&quot;Pologne&quot;</span>, <span style="color: #3366CC;">&quot;Portugal&quot;</span>, <span style="color: #3366CC;">&quot;Russie&quot;</span>, <span style="color: #3366CC;">&quot;Slovaquie&quot;</span>, <span style="color: #3366CC;">&quot;Espagne&quot;</span>, 
<span style="color: #3366CC;">&quot;la Suède&quot;</span>, <span style="color: #3366CC;">&quot;Suisse&quot;</span>, <span style="color: #3366CC;">&quot;Turquie&quot;</span>, <span style="color: #3366CC;">&quot;Royaume-Uni&quot;</span>, <span style="color: #3366CC;">&quot;Uruguay&quot;</span>, <span style="color: #3366CC;">&quot;États-Unis&quot;</span><span style="color: #66cc66;">&#93;</span></pre></div></div>

<p>You can see the incorrect sort order for Germany ("Allemagne") and the US ("États-Unis").<br />
Running the standard javascript <code>Array.sort()</code> will sort it according to the American English language:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript">arr.<span style="color: #006600;">sort</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #009900; font-style: italic;">/*==&gt;
[&quot;Allemagne&quot;, &quot;Argentine&quot;, &quot;Australie&quot;, &quot;Autriche&quot;, &quot;Belgique&quot;, &quot;Brésil&quot;, &quot;Canada&quot;, &quot;Chili&quot;, 
&quot;Chine&quot;, &quot;Corée du Sud&quot;, &quot;Costa Rica &quot;, &quot;Danemark&quot;, &quot;El Salvador &quot;, &quot;Espagne&quot;, &quot;Finlande&quot;, 
&quot;France&quot;, &quot;Guatemala&quot;, &quot;Hong Kong&quot;, &quot;Hongrie&quot;, &quot;Inde&quot;, &quot;Irlande&quot;, &quot;Italie&quot;, &quot;Japon&quot;, 
&quot;Luxembourg&quot;, &quot;Mexique&quot;, &quot;Norvège&quot;, &quot;Nouvelle-Zélande&quot;, &quot;Panama&quot;, &quot;Pays-Bas&quot;, &quot;Pologne&quot;, 
&quot;Portugal&quot;, &quot;Royaume-Uni&quot;, &quot;Russie&quot;, &quot;République Tchèque&quot;, &quot;Slovaquie&quot;, &quot;Suisse&quot;, &quot;Turquie&quot;,
 &quot;Uruguay&quot;, &quot;la Suède&quot;, &quot;Équateur&quot;, &quot;États-Unis&quot;] */</span></pre></div></div>

<p><strong>Note the misplacement of the last three entries.</strong> A real internationalized sort of this would be a huge motherbitch to implement, but here is a quick and hacky way to get your ducks in order:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript">  arr.<span style="color: #006600;">sort</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>a,b<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">function</span> normalize<span style="color: #66cc66;">&#40;</span>str<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
       <span style="color: #000066; font-weight: bold;">return</span> str
               .<span style="color: #006600;">toLowerCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
               .<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066FF;">/è|é|ê|ë/</span>,<span style="color: #3366CC;">'e'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066FF;">/ò|ó|ô|õ|ö/</span>,<span style="color: #3366CC;">'o'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066FF;">/ì|í|î|ï/</span>,<span style="color: #3366CC;">'i'</span><span style="color: #66cc66;">&#41;</span>
               .<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066FF;">/à|á|â|ã|ä|å|æ/</span>,<span style="color: #3366CC;">'a'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066FF;">/ù|ú|û|ü/</span>,<span style="color: #3366CC;">'u'</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    a = normalize<span style="color: #66cc66;">&#40;</span>a<span style="color: #66cc66;">&#41;</span>;
    b = normalize<span style="color: #66cc66;">&#40;</span>b<span style="color: #66cc66;">&#41;</span>;
&nbsp;
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>a &lt; b<span style="color: #66cc66;">&#41;</span> ? <span style="color: #CC0000;">-1</span> : <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>a &gt; b<span style="color: #66cc66;">&#41;</span> ? <span style="color: #CC0000;">1</span> : <span style="color: #CC0000;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #009900; font-style: italic;">/*==&gt;
[&quot;Allemagne&quot;, &quot;Argentine&quot;, &quot;Australie&quot;, &quot;Autriche&quot;, &quot;Belgique&quot;, &quot;Brésil&quot;, &quot;Canada&quot;, &quot;Chili&quot;, 
&quot;Chine&quot;, &quot;Corée du Sud&quot;, &quot;Costa Rica &quot;, &quot;Danemark&quot;, &quot;El Salvador &quot;, &quot;Équateur&quot;, &quot;Espagne&quot;,
 &quot;États-Unis&quot;, &quot;Finlande&quot;, &quot;France&quot;, &quot;Guatemala&quot;, &quot;Hong Kong&quot;, &quot;Hongrie&quot;, &quot;Inde&quot;, &quot;Irlande&quot;, 
&quot;Italie&quot;, &quot;Japon&quot;, &quot;la Suède&quot;, &quot;Luxembourg&quot;, &quot;Mexique&quot;, &quot;Norvège&quot;, &quot;Nouvelle-Zélande&quot;, 
&quot;Panama&quot;, &quot;Pays-Bas&quot;, &quot;Pologne&quot;, &quot;Portugal&quot;, &quot;République Tchèque&quot;, &quot;Royaume-Uni&quot;, 
&quot;Russie&quot;, &quot;Slovaquie&quot;, &quot;Suisse&quot;, &quot;Turquie&quot;, &quot;Uruguay&quot;] */</span></pre></div></div>

<p>It's not perfect (I bet that "la Suède" should actually be in the S's), but it'll get you a bit closer without too much effort.</p>
]]></content:encoded>
			<wfw:commentRss>http://paulirish.com/2008/quick-internationalized-sort-in-javascript/feed/</wfw:commentRss>
		</item>
		<item>
		<title>what makes you sustainably happy?</title>
		<link>http://paulirish.com/2008/what-makes-you-sustainably-happy/</link>
		<comments>http://paulirish.com/2008/what-makes-you-sustainably-happy/#comments</comments>
		<pubDate>Fri, 18 Apr 2008 14:00:41 +0000</pubDate>
		<dc:creator>Paul Irish</dc:creator>
		
		<category><![CDATA[front-end development]]></category>

		<category><![CDATA[hacks]]></category>

		<guid isPermaLink="false">http://paulirish.com/2008/what-makes-you-sustainably-happy/</guid>
		<description><![CDATA[i wonder about the personal fulfillment of:

doing what we think we should be doing
doing what we want to be doing
doing what we think makes us happy

because those three are certainly different..
]]></description>
			<content:encoded><![CDATA[<p>i wonder about the personal fulfillment of:</p>
<ul>
<li>doing what we think we <em>should </em>be doing</li>
<li>doing what we <em>want </em>to be doing</li>
<li>doing what we <em>think </em>makes us happy</li>
</ul>
<p>because those three are certainly different..</p>
]]></content:encoded>
			<wfw:commentRss>http://paulirish.com/2008/what-makes-you-sustainably-happy/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to keep friend requests out of your inbox</title>
		<link>http://paulirish.com/2008/how-to-keep-friend-requests-out-of-your-inbox/</link>
		<comments>http://paulirish.com/2008/how-to-keep-friend-requests-out-of-your-inbox/#comments</comments>
		<pubDate>Tue, 01 Apr 2008 15:57:48 +0000</pubDate>
		<dc:creator>Paul Irish</dc:creator>
		
		<category><![CDATA[hacks]]></category>

		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://paulirish.com/2008/how-to-keep-friend-requests-out-of-your-inbox/</guid>
		<description><![CDATA[If you're incredibly popular on the internet, like me, then I can hear you crying for help. :)
Friend requests littering your inbox can get annoying. They certainly don't need your attention right now, so why not through them to a more passive information consumption area: RSS. That way you can process them en masse, when [...]]]></description>
			<content:encoded><![CDATA[<p>If you're <em>incredibly</em> popular on the internet, like me, then I can hear you crying for help. :)</p>
<p>Friend requests littering your inbox can get annoying. They certainly don't need your attention right now, so why not through them to a more passive information consumption area: <strong>RSS</strong>. That way you can process them en masse, when you're ready to.</p>
<p>First, we use the filters in <strong>Gmail</strong> to identify all friend request emails. </p>
<ul>
<li>Set up a new filter.</li>
<li>In the subject area put in this text:<br /><tt>{"friend request" "is now following you" "newest contact" "friends on yelp" "added you as a" "has requested your trust" "wants to be your friend" "invited you to connect" "would like to be added"}</tt></li>
<li>Click next, then select <b>Skip the Inbox</b></li>
<li>Check <B>Forward it to</b> and in the box put in a <strong><em>unique-email-address</em> @ mailbucket.org</strong>. <em>(For example: paulsfriendrequests@mailbucket.org)</em> This will be a public feed, so... yeah.</li>
<li>Click <b>Create Filter</b></li>
</ul>
<p><img src='http://paulirish.com/wp-content/uploads/2008/04/friendrequestfilter.PNG' alt='friendrequestfilter.PNG' /></p>
<p>Your newly created RSS feed will be at <strong>http://mailbucket.org/<em>unique-email-address</em>.xml</strong>.</p>
<p>This filter will catch all friend requests from: Myspace, Facebook, LinkedIn, Flickr, Spokeo, Twitter, Yelp, and Plaxo Pulse. (And should be pretty trivial to add new ones. :)</p>
]]></content:encoded>
			<wfw:commentRss>http://paulirish.com/2008/how-to-keep-friend-requests-out-of-your-inbox/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to quickly find a layer in a big PSD</title>
		<link>http://paulirish.com/2008/how-to-quickly-find-a-layer-in-a-big-psd/</link>
		<comments>http://paulirish.com/2008/how-to-quickly-find-a-layer-in-a-big-psd/#comments</comments>
		<pubDate>Tue, 04 Mar 2008 22:34:23 +0000</pubDate>
		<dc:creator>Paul Irish</dc:creator>
		
		<category><![CDATA[front-end development]]></category>

		<guid isPermaLink="false">http://paulirish.com/2008/how-to-quickly-find-a-layer-in-a-big-psd/</guid>
		<description><![CDATA[I'll often get PSDs from my visual designers with hundreds of layers. When I'm slicing it up, I'll need to find a specific layer. And much of the time, I don't instantly understand the layer architecture that was defined.
Using the "Auto Select layer" option on the move tool gets partway there, but it chokes on [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://paulirish.com/wp-content/uploads/2008/03/psdlayers.PNG' alt='psdlayers.PNG' align="right" />I'll often get PSDs from my visual designers with hundreds of layers. When I'm slicing it up, I'll need to find a specific layer. And much of the time, I don't instantly understand the layer architecture that was defined.</p>
<p>Using the "Auto Select layer" option on the move tool gets partway there, but it chokes on layer groups.</p>
<p>The quickest route possible: <strong>Alt-right-click</strong><br />
That will immediately select the layer of whatever you clicked on. (The move tool (V) must be active. This doesnt work while on other tools.)</p>
<p><small>(On Mac, this has an additional click: option-click. then the revealed menu has your layer currently selected. click it.)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://paulirish.com/2008/how-to-quickly-find-a-layer-in-a-big-psd/feed/</wfw:commentRss>
		</item>
		<item>
		<title>jQuery doOnce plugin for chaining addicts</title>
		<link>http://paulirish.com/2008/jquery-doonce-plugin-for-chaining-addicts/</link>
		<comments>http://paulirish.com/2008/jquery-doonce-plugin-for-chaining-addicts/#comments</comments>
		<pubDate>Fri, 29 Feb 2008 00:50:55 +0000</pubDate>
		<dc:creator>Paul Irish</dc:creator>
		
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://paulirish.com/2008/jquery-doonce-plugin-for-chaining-addicts/</guid>
		<description><![CDATA[
// jQuery doOnce plugin
jQuery.fn.doOnce = function&#40;func&#41;&#123; 
    func.apply&#40;this&#41;; 
    return this; 
&#125;

This allows you to execute arbitrary script during a single chain. A bad example of alert() debugging follows:

// example usage of doOnce()
$&#40;'div.toGrow'&#41;
  .doOnce&#40;function&#40;&#41;&#123;
    alert&#40;'before color swap'&#41;;
  &#125;&#41;
  .css&#40;&#123; backgroundColor: 'red'&#125;&#41;
  .find&#40;'h2'&#41;
 [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #009900; font-style: italic;">// jQuery doOnce plugin</span>
jQuery.<span style="color: #006600;">fn</span>.<span style="color: #006600;">doOnce</span> = <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>func<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span> 
    func.<span style="color: #006600;">apply</span><span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>; 
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>; 
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>This allows you to execute arbitrary script during a single chain. A bad example of <code>alert()</code> debugging follows:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #009900; font-style: italic;">// example usage of doOnce()</span>
$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'div.toGrow'</span><span style="color: #66cc66;">&#41;</span>
  .<span style="color: #006600;">doOnce</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
    <span style="color: #000066;">alert</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'before color swap'</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
  .<span style="color: #006600;">css</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span> backgroundColor: <span style="color: #3366CC;">'red'</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
  .<span style="color: #006600;">find</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'h2'</span><span style="color: #66cc66;">&#41;</span>
    .<span style="color: #006600;">text</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'And now we<span style="color: #000099; font-weight: bold;">\'</span>re red'</span><span style="color: #66cc66;">&#41;</span>
    .<span style="color: #006600;">end</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #009900; font-style: italic;">// go back to the div.toGrow</span>
  .<span style="color: #006600;">animate</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span> height: <span style="color: #3366CC;">'+=50px'</span><span style="color: #66cc66;">&#125;</span>,<span style="color: #3366CC;">'normal'</span>,<span style="color: #3366CC;">'swing'</span>,<span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
    $<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>  <span style="color: #009900; font-style: italic;">// callback when animations complete</span>
      .<span style="color: #006600;">find</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'h2'</span><span style="color: #66cc66;">&#41;</span>
        .<span style="color: #006600;">text</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'And now we<span style="color: #000099; font-weight: bold;">\'</span>re taller'</span><span style="color: #66cc66;">&#41;</span>
        .<span style="color: #006600;">doOnce</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
          <span style="color: #000066;">alert</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'animation done'</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>Note this is a little different than <code>each()</code>, which will execute once for every element in your current collection.<br />
The code is pretty trivial, but sometimes you just feel like it. Nobody likes to break the chain!</p>
]]></content:encoded>
			<wfw:commentRss>http://paulirish.com/2008/jquery-doonce-plugin-for-chaining-addicts/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to tweak 3rd party scripts “safely”</title>
		<link>http://paulirish.com/2008/how-to-tweak-3rd-party-scripts-safely/</link>
		<comments>http://paulirish.com/2008/how-to-tweak-3rd-party-scripts-safely/#comments</comments>
		<pubDate>Sun, 10 Feb 2008 00:43:56 +0000</pubDate>
		<dc:creator>Paul Irish</dc:creator>
		
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://paul.irish.aurgasm.us/2008/how-to-tweak-3rd-party-scripts-safely/</guid>
		<description><![CDATA[I'm working with some code from MultiMap (basically a Google Maps clone), and unfortunately their API doesn't support real internationalization. There are a number of strings hardcoded in English in their remotely-hosted JS, so this is my deliciously evil way of rectifying the situation.
I first started out redefining their functions in entirety, but that becomes [...]]]></description>
			<content:encoded><![CDATA[<p>I'm working with some code from <a href="http://www.multimap.com">MultiMap</a> (basically a Google Maps clone), and unfortunately their API doesn't support real internationalization. There are a number of strings hardcoded in English in their remotely-hosted JS, so this is my deliciously evil way of rectifying the situation.</p>
<p>I first started out redefining their functions in entirety, but that becomes "dangerous" when they modify a bit of code for a bug fix or something. This revised approach slips in like an evil drunken ninja and only replaces the offending parts. It's still completely crazy, but sometimes there are no better options...</p>

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #009900; font-style: italic;">// WARNING!!  This is such a massive hack. Oh-so-hackalicious</span>
&nbsp;
<span style="color: #009900; font-style: italic;">// Problem:     Multimap doesnt allow internationalization of its buttons, etc.</span>
<span style="color: #009900; font-style: italic;">// Solution:    Redefine their JS functions to use variables that are internationalized.</span>
<span style="color: #009900; font-style: italic;">// Assumption:  That these internal function names stay the same. </span>
<span style="color: #009900; font-style: italic;">// Risk:        If function names change, this code will (probably) silently fail.</span>
&nbsp;
<span style="color: #009900; font-style: italic;">// The following statements change the right-click context menu items and the map/aerial/hybrid buttons.</span>
<span style="color: #009900; font-style: italic;">// Instead of hard-coded strings, it will use a variable which we control.</span>
&nbsp;
<span style="color: #009900; font-style: italic;">// ON TO THE HACKS!!</span>
<span style="color: #009900; font-style: italic;">// Hack 1: modify the mmjr() and mmfl() functions with funcName.toString().replace()</span>
<span style="color: #009900; font-style: italic;">// Hack 2: use eval() to set the definition</span>
<span style="color: #009900; font-style: italic;">// Hack 3: browser sniff because IE and FF handle toString()'d strings differently (single-quote vs double-quote)</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> isIE = $.<span style="color: #006600;">browser</span>.<span style="color: #006600;">msie</span>; <span style="color: #009900; font-style: italic;">// jQuery browser sniff.</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">eval</span><span style="color: #66cc66;">&#40;</span>
  <span style="color: #3366CC;">&quot;mmki.prototype.mmjr = &quot;</span> +  
  mmki.<span style="color: #006600;">prototype</span>.<span style="color: #006600;">mmjr</span>
  .<span style="color: #006600;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
    .<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span> isIE ? <span style="color: #3366CC;">&quot;'Move map to here'&quot;</span> : <span style="color: #3366CC;">'&quot;Move map to here&quot;'</span> ,      <span style="color: #3366CC;">'i18n.retailLocator.moveMapToHere'</span><span style="color: #66cc66;">&#41;</span>
    .<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span> isIE ? <span style="color: #3366CC;">&quot;'Zoom in to here'&quot;</span> : <span style="color: #3366CC;">'&quot;Zoom in to here&quot;'</span> ,        <span style="color: #3366CC;">'i18n.retailLocator.zoomInToHere'</span><span style="color: #66cc66;">&#41;</span>
    .<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span> isIE ? <span style="color: #3366CC;">&quot;'Zoom out from here'&quot;</span> : <span style="color: #3366CC;">'&quot;Zoom out from here&quot;'</span>,   <span style="color: #3366CC;">'i18n.retailLocator.zoomOutFromHere'</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #000066; font-weight: bold;">eval</span><span style="color: #66cc66;">&#40;</span>
  <span style="color: #3366CC;">&quot;MultimapViewer.prototype.mmfl = &quot;</span> +  
  MultimapViewer.<span style="color: #006600;">prototype</span>.<span style="color: #006600;">mmfl</span>
  .<span style="color: #006600;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
    .<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span> isIE ? <span style="color: #3366CC;">&quot;'Map'&quot;</span> : <span style="color: #3366CC;">'&quot;Map&quot;'</span>,       <span style="color: #3366CC;">'i18n.retailLocator.map'</span><span style="color: #66cc66;">&#41;</span>
    .<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span> isIE ? <span style="color: #3366CC;">&quot;'Hybrid'&quot;</span> : <span style="color: #3366CC;">'&quot;Hybrid&quot;'</span>, <span style="color: #3366CC;">&quot;i18n.retailLocator.hybrid&quot;</span><span style="color: #66cc66;">&#41;</span>
    .<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span> isIE ? <span style="color: #3366CC;">&quot;'Aerial'&quot;</span> : <span style="color: #3366CC;">'&quot;Aerial&quot;'</span>, <span style="color: #3366CC;">'i18n.retailLocator.aerial'</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://paulirish.com/2008/how-to-tweak-3rd-party-scripts-safely/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The top 55 best front-end development RSS feeds</title>
		<link>http://paulirish.com/2008/front-end-development-rss-feeds/</link>
		<comments>http://paulirish.com/2008/front-end-development-rss-feeds/#comments</comments>
		<pubDate>Thu, 31 Jan 2008 18:52:42 +0000</pubDate>
		<dc:creator>Paul Irish</dc:creator>
		
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://paul.irish.aurgasm.us/2008/front-end-development-rss-feeds/</guid>
		<description><![CDATA[I've put together all the feeds and blogs that I follow that cover front-end development.
Here is the OPML file: front-end-development-feeds.xml.opml
All the classics like Ajaxian and A List Apart are in here.. but also more technical ninja developers like John Resig, Hedgerwow and Peter Michaux.
If you currently use a RSS aggregator (like Bloglines, Google Reader, or [...]]]></description>
			<content:encoded><![CDATA[<p>I've put together all the <strong>feeds and blogs that I follow that cover front-end development.</strong><br />
Here is the <a href="http://en.wikipedia.org/wiki/OPML">OPML</a> file: <strong style="font-size: 110%"><a href='http://paul.irish.aurgasm.us/wp-content/uploads/2008/01/front-end-development-feedsxml.opml' title='front-end-development-feedsxml.opml'>front-end-development-feeds.xml.opml</a></strong></p>
<p><img src='http://molecularvoices.molecular.com/wp-content/uploads/2008/01/feeds.png' alt='feeds.png' style="float: right" />All the classics like <em>Ajaxian</em> and <em>A List Apart</em> are in here.. but also more technical ninja developers like <a href="http://ejohn.org">John Resig</a>, <a href="http://www.hedgerwow.com/">Hedgerwow</a> and <a href="http://peter.michaux.ca/">Peter Michaux</a>.</p>
<p>If you currently use a RSS aggregator (like <a href="http://www.bloglines.com">Bloglines</a>, <a href="http://reader.google.com">Google Reader</a>, or <a href="http://www.netvibes.com">Netvibes</a>) you can import this file right in.<br />
iGoogle won't take an OPML file but you can do each RSS feed individiually.</p>
<p>You can also preview what's in it here: <a href="http://www.bloglines.com/public/molecular-frontend-feeds">http://www.bloglines.com/public/molecular-frontend-feeds</a></p>
]]></content:encoded>
			<wfw:commentRss>http://paulirish.com/2008/front-end-development-rss-feeds/feed/</wfw:commentRss>
		</item>
	</channel>
</rss><!-- Dynamic Page Served (once) in 10.792 seconds --><!-- Cached page served by WP-Cache -->
