<?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/"
	>

<channel>
	<title>Paul Irish</title>
	<atom:link href="http://paulirish.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://paulirish.com</link>
	<description>I make the www fun.</description>
	<pubDate>Tue, 09 Mar 2010 18:19:10 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Introducing&#8230; CSS3Please.com</title>
		<link>http://paulirish.com/2010/introducing-css3please/</link>
		<comments>http://paulirish.com/2010/introducing-css3please/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 15:54:42 +0000</pubDate>
		<dc:creator>Paul Irish</dc:creator>
		
		<category><![CDATA[front-end development]]></category>

		<guid isPermaLink="false">http://paulirish.com/?p=656</guid>
		<description><![CDATA[
Man, whenever I&#039;m writing some css3, I get so tired of writing all the vendor-specific prefixes (like -moz-border-radius). Combo that with remembering who supports what and I wantedneeded a shortcut.
Today, I&#039;m happy to release v1.0 of css3please.com: a cross-browser css3 rule generator, produced by Jonathan Neal and myself. In addition to syncing and normalizing changes [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://css3please.com"><img src="http://paulirish.com/wp-content/uploads/2010/03/css3pleasess.png" style="border: 1px solid #eee; padding: 10px"></a></p>
<p>Man, whenever I&#039;m writing some css3, I get so tired of writing all the vendor-specific prefixes (like <em>-moz-</em>border-radius). Combo that with remembering who supports what and I <del>wanted</del><ins>needed</ins> a shortcut.</p>
<p>Today, I&#039;m happy to release v1.0 of<strong> <a href="http://css3please.com/">css3please.com: a cross-browser css3 rule generator</a></strong>, produced by <a href="http://twitter.com/jon_neal">Jonathan Neal</a> and myself. In addition to <strong>syncing and normalizing changes</strong> across the necessary properties, it also sneaks in <strong>IE support</strong> for a few features via IE filters. Right now it helps you write the rules for: border-radius, box-shadow, linear-gradients, rotation and @font-face. A few more transforms like skew and scale are on their way, stay tuned.</p>
<p>Shouts to all the good people doing research and making tools in the css3 arena: <a href="http://westciv.com/tools/gradients/">John Allsopp</a>, <a href="http://css-tricks.com/">Chris Coyier</a>, <a href="http://www.phpied.com/css-performance-ui-with-fewer-images/">Stoyan Stefanov</a>, <a href="http://gradients.glrzad.com/">Damian Galarza</a>, <a href="http://www.thecssninja.com/">Ryan Seddon</a>, <a href="http://border-radius.com/">border-radius.com</a>.</p>
<p>Please leave comments and feedback below.</p>
]]></content:encoded>
			<wfw:commentRss>http://paulirish.com/2010/introducing-css3please/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Front-end development feeds to follow</title>
		<link>http://paulirish.com/2010/front-end-development-feeds-to-follow/</link>
		<comments>http://paulirish.com/2010/front-end-development-feeds-to-follow/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 22:54:14 +0000</pubDate>
		<dc:creator>Paul Irish</dc:creator>
		
		<category><![CDATA[front-end development]]></category>

		<guid isPermaLink="false">http://paulirish.com/?p=647</guid>
		<description><![CDATA[If you&#039;re running low on front-end oriented stuff to read, I&#039;ve got 130 feeds of high quality for ya.
Here is the OPML file: frontendfeeds.xml
You can add these to your Google Reader via Settings (in top right), then Import, then upload file.
If you want a peek, a preview via opmlviewer.com.
]]></description>
			<content:encoded><![CDATA[<p>If you&#039;re running low on front-end oriented stuff to read, I&#039;ve got 130 feeds of high quality for ya.</p>
<p>Here is the <a href="http://en.wikipedia.org/wiki/OPML">OPML</a> file: <a href="http://dl.dropbox.com/u/39519/frontendfeeds.xml">frontendfeeds.xml</a></p>
<p>You can add these to your <a href="http://reader.google.com">Google Reader</a> via Settings (in top right), then Import, then upload file.</p>
<p>If you want a peek, a <a href="http://opmlviewer.com/Viewer/?http://dl.dropbox.com/u/39519/frontendfeeds.xml">preview via opmlviewer.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://paulirish.com/2010/front-end-development-feeds-to-follow/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to fulfill your own feature request -or- Duck Punching with jQuery!</title>
		<link>http://paulirish.com/2010/duck-punching-with-jquery/</link>
		<comments>http://paulirish.com/2010/duck-punching-with-jquery/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 18:27:50 +0000</pubDate>
		<dc:creator>Paul Irish</dc:creator>
		
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://paulirish.com/?p=629</guid>
		<description><![CDATA[Wait, what? Well first, duck punching is another name for monkey patching. Monkey Patching is a technique to &#034;extend or modify the runtime code of dynamic languages without altering the original source code.&#034; But then some Ruby hackers decided that since we rely on duck typing so often, a more proper name was in order:
&#8230; [...]]]></description>
			<content:encoded><![CDATA[<p>Wait, what? Well first, duck punching is another name for monkey patching. <a href="http://en.wikipedia.org/wiki/Monkey_patch">Monkey Patching</a> is a technique to &#034;extend or modify the runtime code of dynamic languages without altering the original source code.&#034; But then some Ruby hackers decided that since we rely on <a href="http://en.wikipedia.org/wiki/Duck_typing">duck typing</a> so often, a more proper name was in order:</p>
<blockquote style="clear:right"><p>&#8230; if it walks like a duck and talks like a duck, it’s a duck, right? So if this duck is not giving you the noise that you want, <b>you’ve got to just punch that duck until it returns what you expect</b>.<sup><a href="http://podcast.rubyonrails.org/programs/1/episodes/railsconf-2007">[1]</a></sup></p></blockquote>
<p><img src="http://paulirish.com/wp-content/uploads/2010/02/duckpunch.jpg" height="214" style="border: 1px solid #eee; padding: 10px; margin: 10px "><br />
In jQuery we can use this to great effect. We&#039;ll employ an AOP-like approach (<a href="http://en.wikipedia.org/wiki/Aspect-oriented_programming">aspect-oriented programming</a>), maintaining the original function but wrapping it with our enhancement.</p>
<h4>Example 1: Adding color support</h4>
<p>(This is a silly example, but hopefully it explains the idea. )<br />
You&#039;re fully aware that you can use certain <A href="http://en.wikipedia.org/wiki/X11_color_names">color names</a> in HTML. But sadly, everyone&#039;s favorite Crayola&trade; color, Burnt Sienna, can&#039;t play along. Well, not until now&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> _oldcss <span style="color: #339933;">=</span> $.<span style="color: #660066;">fn</span>.<span style="color: #660066;">css</span><span style="color: #339933;">;</span>
&nbsp;
    $.<span style="color: #660066;">fn</span>.<span style="color: #660066;">css</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>prop<span style="color: #339933;">,</span>value<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/^background-?color$/i</span>.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span>prop<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> value.<span style="color: #660066;">toLowerCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #3366CC;">'burnt sienna'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
           <span style="color: #000066; font-weight: bold;">return</span> _oldcss.<span style="color: #660066;">call</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span>prop<span style="color: #339933;">,</span><span style="color: #3366CC;">'#EA7E5D'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
           <span style="color: #000066; font-weight: bold;">return</span> _oldcss.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span>arguments<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// and using it...</span>
jQuery<span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">body</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'backgroundColor'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'burnt sienna'</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>Let&#039;s walk through that a little bit slower, shall we? </p>
<p>First we start off with a self-executing anonymous function that makes a happy closure while remapping jQuery to $:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">// ...</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Now we save a reference to the old css method as a local variable, and set up our new definition for that method:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">    <span style="color: #003366; font-weight: bold;">var</span> _oldcss <span style="color: #339933;">=</span> $.<span style="color: #660066;">fn</span>.<span style="color: #660066;">css</span><span style="color: #339933;">;</span>
&nbsp;
    $.<span style="color: #660066;">fn</span>.<span style="color: #660066;">css</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>prop<span style="color: #339933;">,</span>value<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// ....</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Inside our function definition we have an if statement that breaks up two code paths, the new enhanced route, and the old default:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">        <span style="color: #006600; font-style: italic;">// if the user passed in backgroundColor and 'burnt sienna'</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/^background-?color$/i</span>.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span>prop<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> value.<span style="color: #660066;">toLowerCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #3366CC;">'burnt sienna'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
            <span style="color: #006600; font-style: italic;">// call the old css() method with this hardcoded color value</span>
            <span style="color: #000066; font-weight: bold;">return</span> _oldcss.<span style="color: #660066;">call</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span>prop<span style="color: #339933;">,</span><span style="color: #3366CC;">'#EA7E5D'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #006600; font-style: italic;">// otherwise call the old guy normally, taking his return value and passing it on.</span>
            <span style="color: #000066; font-weight: bold;">return</span> _oldcss.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span>arguments<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Scroll back up to see the whole thing together. Can you dig it?</p>
<h4>Example 2: $.unique() enhancement</h4>
<p>$.unique only winnows an array of DOM elements to contain no duplicates, but what if you want all non-duplicates of any type? Here&#039;s an upgrade:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> _old <span style="color: #339933;">=</span> $.<span style="color: #660066;">unique</span><span style="color: #339933;">;</span>
&nbsp;
    $.<span style="color: #660066;">unique</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>arr<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// do the default behavior only if we got an array of elements</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!!</span>arr<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">nodeType</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">return</span> _old.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span>arguments<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #006600; font-style: italic;">// reduce the array to contain no dupes via grep/inArray</span>
            <span style="color: #000066; font-weight: bold;">return</span> $.<span style="color: #660066;">grep</span><span style="color: #009900;">&#40;</span>arr<span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>v<span style="color: #339933;">,</span>k<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">return</span> $.<span style="color: #660066;">inArray</span><span style="color: #009900;">&#40;</span>v<span style="color: #339933;">,</span>arr<span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> k<span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// in use..</span>
<span style="color: #003366; font-weight: bold;">var</span> arr <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'first'</span><span style="color: #339933;">,</span><span style="color: #CC0000;">7</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span><span style="color: #CC0000;">7</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'last'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'last'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
$.<span style="color: #660066;">unique</span><span style="color: #009900;">&#40;</span>arr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// [&quot;first&quot;, 7, true, 2, &quot;last&quot;]</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> arr <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span><span style="color: #CC0000;">3</span><span style="color: #339933;">,</span><span style="color: #CC0000;">4</span><span style="color: #339933;">,</span><span style="color: #CC0000;">5</span><span style="color: #339933;">,</span><span style="color: #CC0000;">4</span><span style="color: #339933;">,</span><span style="color: #CC0000;">3</span><span style="color: #339933;">,</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
$.<span style="color: #660066;">unique</span><span style="color: #009900;">&#40;</span>arr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// [1, 2, 3, 4, 5]</span></pre></div></div>

<h4>A Duck Punching Pattern</h4>
<p>Here&#039;s the bare pattern. Feel free to use this as the basis of your own:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">// store original reference to the method</span>
    <span style="color: #003366; font-weight: bold;">var</span> _old <span style="color: #339933;">=</span> $.<span style="color: #660066;">fn</span>.<span style="color: #660066;">method</span><span style="color: #339933;">;</span>
&nbsp;
    $.<span style="color: #660066;">fn</span>.<span style="color: #660066;">method</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>arg1<span style="color: #339933;">,</span>arg2<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> ... <span style="color: #660066;">condition</span> ... <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
           <span style="color: #000066; font-weight: bold;">return</span>  .... 
        <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>           <span style="color: #006600; font-style: italic;">// do the default</span>
           <span style="color: #000066; font-weight: bold;">return</span> _old.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span>arguments<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h4>What else could I use this for?</h4>
<p>Some other uses I&#039;ve had or seen for this sort of thing:</p>
<ul>
<li><a href="http://pastie.org/701232">throwing an exception when $.fn.find returns a 0-length object</a></li>
<li><a href="http://github.com/paulirish/jQuery-miniplugins/blob/master/cssmonkeypatch.js">returning the shorthand value when asking for $(elem).css(&#039;margin&#039;)</a></li>
<li><a href="http://ralphholzmann.com/2010/01/fadein_and_jquery-goodness/">removing IE&#039;s filter attribute after a fade</a></li>
<li><a href="http://github.com/ralphholzmann/jquery-goodness/blob/master/monkey-patches.js">next(2) goes to the subsequent adjacent node</a></li>
<li><a href="http://github.com/jamespadolsey/jQuery-plus">&#8230; and James Padolsey&#039;s jQuery-Plus has a bunch of more these</a></li>
</ul>
<p>So while you&#039;re free to file a feature request of jQuery, most of the time you can actually enhance jQuery&#039;s methods yourself! Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://paulirish.com/2010/duck-punching-with-jquery/feed/</wfw:commentRss>
		</item>
		<item>
		<title>On jQuery&#039;s live()</title>
		<link>http://paulirish.com/2010/on-jquery-live/</link>
		<comments>http://paulirish.com/2010/on-jquery-live/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 17:59:57 +0000</pubDate>
		<dc:creator>Paul Irish</dc:creator>
		
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://paulirish.com/?p=572</guid>
		<description><![CDATA[Since the release of 1.4, there&#039;s been a lot of discussion about live(). Now that it&#039;s almost as fully featured as bind(), it&#039;s getting quite a workout.
One of the larger calls to action is to introduce $.live(selector,eventType,handler). There are two primary reasons I&#039;ve seen behind this proposal:

There is a performance hit for the initial selection [...]]]></description>
			<content:encoded><![CDATA[<p>Since the <a href="http://jquery14.com/day-01/jquery-14">release of 1.4</a>, there&#039;s been a lot of discussion about <code>live()</code>. Now that it&#039;s almost as fully featured as <code>bind()</code>, it&#039;s getting quite a workout.</p>
<p>One of the larger calls to action is to introduce <code>$.live(selector,eventType,handler)</code>. There are two primary reasons I&#039;ve seen behind this proposal:</p>
<ol>
<li>There is a performance hit for the initial selection in <code>$('a.whatever').live(</code>.. that isn&#039;t neccessary</li>
<li><code>live()</code> cannot work on any arbitrary collection of DOM elements in jQuery object, as a side effect of a very different internal operation, thus providing an inconsistent developer experience than all other $.fn.foo methods.</li>
</ol>
<h4>$.live for performance</h4>
<p>Sizzle is used to find any matching elements before the live method discards them an only uses the jQobj.selector property and context. It&#039;s a waste, I agree. But you can avoid it. <a href="http://www.zachleat.com/web/2009/05/08/performance-caveat-with-jquery-selectors-and-live-events/">Zachleat posted this technique</a> first. Then I stole a code snippet from <a href="http://twitter.com/janl">@janl</a> to show off in my <a href="http://paulirish.com/perf" title="slide 35">jQuery Performance talk</a> for jQCon. This inspired <a href="http://github.com/furf/jquery-live">furf&#039;s jQuery.live()</a> patch. And now <a href="http://forum.jquery.com/topic/jquery-live-jquery-fn-live-discussion">jmar777 has resurrected</a> that discussion. </p>
<p><strong>I do not think the performance gain in <code>$.live</code> is worth adding it to jQuery core</strong>, by any means. Let&#039;s take an example.</p>
<blockquote style="background-image:none"><p>
Let&#039;s say we&#039;re dealing with <code>$(selector).live('click',fn)</code></p>
<p>On every click on the page, the event is caught at the context.. the <code>document</code>. But <code>evt.target</code> points to the top-most element that was clicked on.<br />
jQuery then traverses from evt.target through each ancestor of that node all the way up to document checking <code>if (jQuery(elem).is(selector))</code>.<sup>[<a href="http://gist.github.com/277432#LID3632">source</a>]</sup></p>
<p>I think a reasonable estimated depth of evt.targets is like 8 (From the document to HTML element to BODY and so on.. a depth of 20 is not uncommon by any means). And lets say we have an average 5 clicks on a page.<br />
That&#039;s 40 total checks against the <code>selector</code> (plus the original one done at bind time).<br />
So in my opinion a 1/41 speed gain isn&#039;t worth changing the API.
</p></blockquote>
<p>Scoping the delegation a context, however has a much larger impact on performance: <code>$(selector,elem).live('click',fn)</code> Here, only clicks within the context are caught, so not only is the parent traversal depth much more shallow, but that entire sequence is avoided for all events occurring outside that area. </p>
<p>The current API to take advantage of this optimization requires code like <code>$('a.awesome', $('#box')[0]).live(&#8230;</code> Yuck! So I <a href="http://github.com/paulirish/jquery/commit/3a5d3a9a922b9c53866931a449abd3d9c79e537d">wrote a patch to deliver this same optimization</a> to any ID-rooted selectors. (The perk being that everyone who learns #id-rooted selectors are fast for selecting get a related perf boost here). But as Justin Meyer pointed out in the comments, it&#039;s not as flexible as live() currently is.</p>
<h4>$.fn.live cannot operate on any jQuery-wrapped collection of elements</h4>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a.foo'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">filter</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.bar'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">live</span><span style="color: #009900;">&#40;</span>... <span style="color: #006600; font-style: italic;">// fails</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a.link'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">nextAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">live</span><span style="color: #009900;">&#40;</span>... <span style="color: #006600; font-style: italic;">// fails</span>
$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">live</span><span style="color: #009900;">&#40;</span>... <span style="color: #006600; font-style: italic;">// fails</span></pre></div></div>

<p>Quite simply, <code>$.fn.live</code> needs to be at the top of a chain to guarantee the <code>.selector</code> and <code>.context</code> properties of the jQuery object represent that set. Unlike other $.fn methods, live utilizes those properties and <i>not</i> the actual collection of elements that result from selection, traversing, and filtering.</p>
<h4>$.live() and let $.die()</h4>
<p>What are the possible solutions?</p>
<ol>
<li><b>Turn on a dirty flag in traversal methods</b>, so if you try and live() that collection, it will throw an error.</li>
<li><strong>Deprecate $.fn.live and use $.live(selector[,context],type,handler)</strong></li>
<li><strong>Use $.live to create a &#034;live jQuery object&#034;</strong> that defaults to live-bindings: <code>$.live(selector,context).click(fn).mouseenter(fn).unbind("click")</code> <sup>[<a href="http://pastie.org/790043">source</a>]</sup></li>
<li><b>Change $.fn.live to operate from a context:</b> <code>$(context).live('selector', event, fn)</code> This bakes the performance benefit from above right in.</li>
</ol>
<p>Any others? What do you guys think? Is there a solution that preserves backwards-compatibility while solving the issue?</p>
<p><small>btw- thx to jmar777, yehuda katz, ben alman, ajpiano, brandon aaron and julian aubourg for their great thoughts on the issue.</small></p>
<div class="update">The people in this discussion got together and hashed out what would make sense. John Resig then <a href="http://github.com/jquery/jquery/commit/31432e048f879b93ffa44c39d6f5989ab2620bd8">landed a new delegate/undelegate API</a>. It&#039;s good. :)</div>
]]></content:encoded>
			<wfw:commentRss>http://paulirish.com/2010/on-jquery-live/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Updates from all around - Dec 2009</title>
		<link>http://paulirish.com/2009/updates-from-all-around-dec-2009/</link>
		<comments>http://paulirish.com/2009/updates-from-all-around-dec-2009/#comments</comments>
		<pubDate>Sat, 19 Dec 2009 22:04:28 +0000</pubDate>
		<dc:creator>Paul Irish</dc:creator>
		
		<category><![CDATA[javascript]]></category>

		<category><![CDATA[jquery]]></category>

		<category><![CDATA[typography]]></category>

		<guid isPermaLink="false">http://paulirish.com/?p=559</guid>
		<description><![CDATA[A lot of the work I&#039;m doing doesn&#039;t turn into new posts so here&#039;s a summary of what&#039;s been going on:
yayQuery
Since it was announced here, we&#039;ve come a long way. We just put out our 7th episode (now in HD!). The show format has tightened up and we&#039;re putting a lot of time into making [...]]]></description>
			<content:encoded><![CDATA[<p>A lot of the work I&#039;m doing doesn&#039;t turn into new posts so here&#039;s a summary of what&#039;s been going on:</p>
<h4>yayQuery</h4>
<p><a href="http://yayquery.com"><img align="right" src="http://paulirish.com/wp-content/uploads/2009/12/yayquerylogo.png"></a>Since it was announced here, we&#039;ve come a long way. We just put out <a href="http://yayquery.com" title="view source for funtimes, too">our 7th episode</a> (now in HD!). The show format has tightened up and we&#039;re putting a lot of time into making it even better. <a href="http://twitter.com/yayQuery">Follow us on twitter</a> or subscribe to catch all the goodness. We also put out an entire episode devoted to what&#039;s coming in jQuery 1.4 (aka 1.MOAR), so peep it if you&#039;re curious.</p>
<h5>jQuery Singalong plugin</h5>
<p>I was a finalist at Boston&#039;s <a href="http://musichackdayboston.pbworks.com/">Music Hack Day</a> with the <a href="http://yayquery.github.com/jquery-singalong/">jQuery Singalong plugin</a>. It essentially allows you to add timed annotations to the HTML5 audio and video elements. (Also it was the first time I legitimately used javascript&#039;s <code>Infinity</code> :) In addition, I put out the <small>(very!)</small> alpha jQuery Bouncing Ball plugin. Check out <a href="http://yayquery.github.com/jquery-singalong/">the demos to get a taste</a> </p>
<h4>Modernizr updates</h4>
<p><a href="http://www.modernizr.com"><img align="left" src="http://paulirish.com/wp-content/uploads/2009/12/logo.png"></a>Faruk and I pushed out <a href="http://www.modernizr.com/releases/">Modernizr 1.1</a>, which can now detect what audio/video formats your browser supports, all sorts of HTML5 forms goodness, and some other ones like localStorage and applicationCache. We&#039;re delighted to be part of Mark Pilgrim&#039;s <a href="http://diveintohtml5.org/detect.html">Dive into HTML5 book</a> and pumped to help push the edge of progressive enhancement.</p>
<h4>@font-face and webfonts</h4>
<p>It&#039;s a rapidly changing landscape, so I&#039;ve been keeping all my <a title="category/typography" href="http://paulirish.com/category/typography/">font-y posts</a> up to date:</p>
<ul>
<li><a href="http://paulirish.com/2009/fighting-the-font-face-fout/">Fighting the @font-face FOUT</a> now has a <i>Defeat the FOUT entirely</i> script and detail on when FOUT occurs</li>
<li><a href="http://paulirish.com/2009/chrome-and-font-face-a-summary/#update/">Chrome and @font-face</a> now represents the latest status and info.</li>
<li><a href="http://paulirish.com/2009/bulletproof-font-face-implementation-syntax/">Bulletproof @font-face syntax</a> now features detail and helpful links when it comes to SVG/WOFF along with the latest gotcha&#039;s.</li>
</ul>
<h5>@font-face feature detection</h5>
<p>I&#039;ve updated the <a href="http://paulirish.com/2009/font-face-feature-detection/">existing feature detection script</a> to use a smaller file. (Thanks to the <a href="http://fontsquirrel.com">Font Squirrel</a> for the help). You would use this script to detect if support is present or not; perhaps implement a Cufon fallback. These new improvements will make their way into Modernizr 1.2.</p>
<p>I&#039;ve also added on a isFontFaceSupported <a href="http://paulirish.com/2009/font-face-feature-detection/#sniff">browser sniffing alternative</a>. The main benefit here is that you&#039;re guaranteed accurate results synchronously. (The true feature detection can&#039;t do that,  though the new small size is much faster in Firefox.)</p>
<h4>Other bits and bobs</h4>
<p>The nice guys at that <i title="tee hee">other</i> jQuery Podcast <a href="http://bit.ly/8zaike">had me on the show</a> in November. I talked about, well.. basically all of the stuff above. :) It&#039;s a good show.</p>
<p>I tweeted about a new quick approach to a for loop:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> len <span style="color: #339933;">=</span> arr.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span>i <span style="color: #339933;">&lt;</span> len<span style="color: #339933;">;</span> <span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">// the cool guy loop</span></pre></div></div>

<p>The fun part is that the counting expression (the third part) is empty. It&#039;s <a title="Screenshots showing it's perf increase" href="http://paulirish.com/i/d9f0.png">faster</a> than your standard loops, but reverse while() is still quicker. <small>@jdalton beat me to this one, for the record.</small></p>
<p>Lastly, along with my writers, I&#039;ve been keeping my mp3 blog <a href="http://aurgasm.us">Aurgasm</a> fresh with new music you&#039;ll love. I&#039;ve got a lot more things in the pipeline, so right after my Christmas and New Years jaunt around Germany, Denmark, and Scotland, you&#039;ll see them soon. Happy December ya&#039;ll.</p>
]]></content:encoded>
			<wfw:commentRss>http://paulirish.com/2009/updates-from-all-around-dec-2009/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Memorable hex colors</title>
		<link>http://paulirish.com/2009/memorable-hex-colors/</link>
		<comments>http://paulirish.com/2009/memorable-hex-colors/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 05:50:07 +0000</pubDate>
		<dc:creator>Paul Irish</dc:creator>
		
		<category><![CDATA[front-end development]]></category>

		<guid isPermaLink="false">http://paulirish.com/?p=517</guid>
		<description><![CDATA[Hopefully this will save you a trip back to Photoshop&#039;s color picker. 

#b00b00
#de1e7e
#e1e100
#BADA55
#F0FEAF
#ac1d1c
#facade

These ones are memorable, but not terribly color-appropriate:

 #c0ffee
 #defec8
 #deface
 #0ff1ce
 #a55

Thx for the awesome suggestions: @mrspeaker, @8centsaday, @wilto, @lrbabe, @twalve
If you have any good ones to add, holler in the comments! 

#post-517 li {
font-family:Consolas,Courier,Courier New;
font-size:20px;
height:19px;
line-height:21px;
list-style-type:none;
margin:5px;
padding:4px;
width:85px;
}


function contrast(color){ return '#' + 
  [...]]]></description>
			<content:encoded><![CDATA[<p>Hopefully this will save you a trip back to Photoshop&#039;s color picker. </p>
<ul>
<li title="great for errors!">#b00b00</li>
<li title="Are you sure you want to delete? Confirm!">#de1e7e</li>
<li title="old mcdonald had a farm..">#e1e100</li>
<li title="naturally">#BADA55</li>
<li title="highlights!">#F0FEAF</li>
<li title="corrosive! omg!">#ac1d1c</li>
<li title="pink. totally.">#facade</li>
</ul>
<p>These ones are memorable, but not terribly color-appropriate:</p>
<ul>
<li> #c0ffee</li>
<li> #defec8</li>
<li> #deface</li>
<li> #0ff1ce</li>
<li> #a55</li>
</ul>
<p>Thx for the awesome suggestions: <a href="http://twitter.com/mrspeaker">@mrspeaker</a>, <a href="http://twitter.com/8centsday">@8centsaday</a>, <a href="http://twitter.com/wilto">@wilto</a>, <a href="http://twitter.com/lrbabe">@lrbabe</a>, <a href="http://twitter.com/twalve">@twalve</a><br />
If you have any good ones to add, holler in the comments! </p>
<style>
#post-517 li {
font-family:Consolas,Courier,Courier New;
font-size:20px;
height:19px;
line-height:21px;
list-style-type:none;
margin:5px;
padding:4px;
width:85px;
}
</style>
<p><script>
function contrast(color){ return '#' + 
   (Number('0x'+color.substr(1)).toString(10) > 0xffffff/2 ? '000000' :  'ffffff'); 
}
$(function(){
$('#post-517 .content li').each(function(){ 
   var color = $(this).text().toUpperCase().replace(/\s+/g,'');
   $(this).css({background: color , color : contrast(color)} );
});
});
</script></p>
<p>I guess I have <a href="http://paulirish.com/2009/random-hex-color-code-snippets/">a thing for hex colors</a>.. ;)</p>
]]></content:encoded>
			<wfw:commentRss>http://paulirish.com/2009/memorable-hex-colors/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Announcing the Type Rendering project</title>
		<link>http://paulirish.com/2009/announcing-the-type-rendering-project/</link>
		<comments>http://paulirish.com/2009/announcing-the-type-rendering-project/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 14:27:00 +0000</pubDate>
		<dc:creator>Paul Irish</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://paulirish.com/?p=529</guid>
		<description><![CDATA[A short while ago, I pulled together some bright minds in the emerging web fonts scene: Tim Brown of Nice Web Type, Zoltan Hawryluk, and Ethan Dunham of Font Squirrel. I thought it would be wise to share notes and begin talking about cross-platform/browser type rendering (that lasagna of complexity), in order to clarify the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://typerendering.com/"><img src="http://paulirish.com/wp-content/uploads/2009/11/r.png" align="right" width="200" height="200"></a>A short while ago, I pulled together some bright minds in the emerging web fonts scene: Tim Brown of <a href="http://www.nicewebtype.com">Nice Web Type</a>, <a href="http://www.useragentman.com/blog/">Zoltan Hawryluk</a>, and Ethan Dunham of <a href="http://www.fontsquirrel.com/">Font Squirrel</a>. I thought it would be wise to share notes and begin talking about cross-platform/browser type rendering (that <a href="http://www.alistapart.com/articles/real-web-type-in-real-web-context/">lasagna of complexity</a>), in order to clarify the entire process for ourselves and others and find ways to make web type look better.</p>
<p><strong>Basically, I want @font-face text to look damn good.</strong></p>
<p>Now we&#039;ve <a href="http://typerendering.com/">set some goals</a> and would like to open up the dialogue. We&#039;ll need your participation, and lots of expert advice, to fulfill these intentions. <strong class="highlight">Follow <a href="http://twitter.com/typerendering">Type Rendering on Twitter</a>.</strong></p>
<p>Check out <a href="http://www.useragentman.com/blog/2009/11/29/how-to-detect-font-smoothing-using-javascript/">How to Detect Font-Smoothing Using JavaScript</a> to learn about an algorithm Zoltan has developed for determining whether a visitor&#039;s web browser uses font smoothing technology when rendering type.</p>
<p>If you want to see rich typography succeed, tell folks <a href="http://twitter.com/home?status=I+care+about+how+type+looks+on+the+web,+so+I+follow+%40typerendering.">you care about how type looks</a> on the web.</p>
<p>We&#039;ll be exploring all the layers involved in making sure web fonts are implemented in the best possible way. We&#039;ll need your help, too.</p>
]]></content:encoded>
			<wfw:commentRss>http://paulirish.com/2009/announcing-the-type-rendering-project/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Infinite Scroll 1.4 is out. Twitter-style now supported!</title>
		<link>http://paulirish.com/2009/infinite-scroll-14-is-out-twitter-style-now-supported/</link>
		<comments>http://paulirish.com/2009/infinite-scroll-14-is-out-twitter-style-now-supported/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 05:40:12 +0000</pubDate>
		<dc:creator>Paul Irish</dc:creator>
		
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://paulirish.com/?p=523</guid>
		<description><![CDATA[I just released version 1.4 of the jQuery Infinite Scroll plugin. Along with that comes a new release of the wordpres plugin. A few small bugs were fixed in the wordpress code, improving compatibility with other plugins and themes.
I&#039;ve also added the ability to manually trigger loading in new content. This allows you to do [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.infinite-scroll.com/wp-content/uploads/2008/07/infinite-scroll-pattern.gif" align="right">I just released version 1.4 of the <a href="http://www.infinite-scroll.com/infinite-scroll-jquery-plugin/">jQuery Infinite Scroll plugin</a>. Along with that comes a new release of the wordpres plugin. A few small bugs were fixed in the wordpress code, improving compatibility with other plugins and themes.</p>
<p>I&#039;ve also added the ability to manually trigger loading in new content. This allows you to do a twitter or facebook style of interaction where the user must click an element for the new data to come in. </p>
<p><a href="http://www.infinite-scroll.com/trigger.html">A demo showing that functionality.</a> The documentation of how to use this style is on the <a href="http://www.infinite-scroll.com/infinite-scroll-jquery-plugin/">documentation page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://paulirish.com/2009/infinite-scroll-14-is-out-twitter-style-now-supported/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Introducing yayQuery - A jQuery podcast</title>
		<link>http://paulirish.com/2009/introducing-yayquery-a-jquery-podcast/</link>
		<comments>http://paulirish.com/2009/introducing-yayquery-a-jquery-podcast/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 14:53:02 +0000</pubDate>
		<dc:creator>Paul Irish</dc:creator>
		
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://paulirish.com/?p=487</guid>
		<description><![CDATA[A few friends of mine got together to put together a new podcast we&#039;re calling&#8230;
yayQuery!
2009.11.13. Now visit the podcast at:
http://yayquery.com

In our inaugural episode I&#039;m joined by Rebecca Murphey, Alex Sexton (of goto.js fame), and Adam Sontag (ajpiano). We talk about&#8230;

Underscore.js - a great utility belt (very handy for Ruby/Python folks), comes with John Resig&#039;s microtemplating [...]]]></description>
			<content:encoded><![CDATA[<p>A few friends of mine got together to put together a new podcast we&#039;re calling&#8230;</p>
<h4>yayQuery!</h4>
<div class="update">2009.11.13. Now visit the podcast at:<br />
<a href="http://yayquery.org" style="display:block; font-size: 18px;">http://yayquery.com</a>
</div>
<p>In our inaugural episode I&#039;m joined by <a href="http://blog.rebeccamurphey.com/">Rebecca Murphey</a>, <a href="http://alexsexton.com/">Alex Sexton</a> (of <a href="http://www.summerofgoto.com">goto.js</a> fame), and Adam Sontag (ajpiano). We talk about&#8230;</p>
<ul>
<li><a href="http://documentcloud.github.com/underscore/">Underscore.js</a> - a great utility belt (very handy for Ruby/Python folks), comes with John Resig&#039;s microtemplating script and lots more</li>
<li>Thickbox - <a href="http://jquery.com/demo/thickbox/">Rest in peace</a>. Also alternatives: <a href="http://colorpowered.com/colorbox/">Colorbox</a>, <a href="http://jqueryui.com/demos/dialog/">jQuery UI Dialog</a></li>
<li>jQuery on mobile. <a href="http://phonegap.com/">Phonegap</a>, <a href="http://xuijs.com/">XUI</a>, <a href="http://www.jqtouch.com/">jQTouch</a>, going it alone</li>
<li>Anti-Pattern of the week: css(key,val)</li>
<li>$var and Hungarian notation</li>
<li>&#8230; and dancing</li>
</ul>
<h4>Moar?</h4>
<p>We hope to do this again (and again) and make things better. We&#039;re also working on proper podcast feeds and a site.</p>
<p>But really this is an experiment, for now. We&#039;d love any and all feedback.</p>
<p><a href="http://twitter.com/yayquery/" ><strong>&#8230; and follow us on twitter to get your fix!! @yayquery</strong></a></p>
]]></content:encoded>
			<wfw:commentRss>http://paulirish.com/2009/introducing-yayquery-a-jquery-podcast/feed/</wfw:commentRss>
<enclosure url="http://paulirish.com/yayQuery/yayQuery_1.0.ogv" length="63707540" type="video/ogg" />
<enclosure url="http://paulirish.com/yayQuery/yayQuery_1.0.mp4" length="98775887" type="video/mp4" />
<enclosure url="http://paulirish.com/yayQuery/yayQuery_1.0.mp3" length="31439904" type="audio/mpeg" />
		</item>
		<item>
		<title>Fighting the @font-face FOUT - Quicken the load time</title>
		<link>http://paulirish.com/2009/fighting-the-font-face-fout/</link>
		<comments>http://paulirish.com/2009/fighting-the-font-face-fout/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 03:18:34 +0000</pubDate>
		<dc:creator>Paul Irish</dc:creator>
		
		<category><![CDATA[front-end development]]></category>

		<category><![CDATA[typography]]></category>

		<guid isPermaLink="false">http://paulirish.com/?p=451</guid>
		<description><![CDATA[FOUT is what I&#039;m calling the flash of unstyled text that you get while using @font-face in Firefox and Opera.
In June, Remy Sharp documented the how a browser progressively renders a page using @font-face.  Things work differently between browsers natch:
Here&#039;s how in Firefox; basically the text is in a default webfont until the custom [...]]]></description>
			<content:encoded><![CDATA[<p><abbr title="Flash of unstyled text">FOUT</abbr> is what I&#039;m calling the flash of unstyled text that you get while using @font-face in Firefox and Opera.</p>
<p>In June, <a href="http://remysharp.com/2009/06/23/safaris-problem-with-font-face/">Remy Sharp documented the how a browser progressively renders a page using @font-face</a>.  Things work differently between browsers natch:</p>
<p>Here&#039;s how in Firefox; basically the text is in a default webfont until the custom font is ready:<br />
<img src="http://paulirish.com/wp-content/uploads/2009/10/fontface-download-gecko.jpg" title="gecko &#038; presto's progressive rendering"></p>
<p>Webkit takes a very different <a href="http://webkit.org/blog/66/the-fouc-problem/">approach</a>, and very intentionally. They believe it&#039;s better to keep the text invisible until the font is ready. This way, there is no moment where the text flashes into its newly upgraded self. (This moment should be familiar to you if you&#039;ve used sIFR)<br />
<img src="http://paulirish.com/wp-content/uploads/2009/10/fontface-download-webkit.jpg" title="webkit's progressive rendering"></p>
<p>I really don&#039;t like the text upgrade FOUT, so I personally prefer webkit&#039;s technique. But either way, we want the font loaded ASAP, so let&#039;s speed it up!</p>
<h4>Best practices for serving fonts:</h4>
<ul>
<li>Minimize the overall kilobyte size of your font file. You can reduce the size of your font file by subsetting it <small>(more on this later)</small>. </li>
<li>Heavy caching via a far-future expires header.</li>
<li>Gzip? <del>Well, no; you can&#039;t gzip a font file</del>, though you can gzip a css file that holds the data-uri representation, but you don&#039;t get much gain there. It&#039;d primarily be an obfuscation technique.<ins>Stoyan Stefanov has done some <a href="http://www.phpied.com/gzip-your-font-face-files/">excellent research into @font-face and gzip</a>. Summary: It&#039;s possible! 40-45% savings. Do It!</ins></li>
</ul>
<h4>When exactly do browsers download the font file?</h4>
<p>Garrick at <a href="http://www.kernest.com">Kernest</a> tipped me off to IE&#039;s interesting behavior here.</p>
<p>After some research we can see when the asset download is initiated:</p>
<ul>
<li>IE will download the .eot file immediately when it encounters the @font-face declaration.</li>
<li>No browsers download the font file when they find a css rule that references the @font-face font.</li>
<li>Gecko, Webkit, and Opera all wait until they encounter HTML that matches a CSS rule with a fontstack including the @font-face font.</li>
</ul>
<p>I&#039;ve put up <a href="http://dl.getdropbox.com/u/39519/webfontsdemo/loadtest.html">a test page where you can experiment</a> and watch your dev tools to see when the file is grabbed.</p>
<h5>In what cases will you get a FOUT</h5>
<ul>
<li><strong>Will: </strong>Downloading and displaying a remote ttf/otf/woff</li>
<li><strong>Will: </strong>Displaying a cached ttf/otf/woff</li>
<li><strong>Will: </strong>Downloading and displaying a data-uri ttf/otf/woff</li>
<li><strong>Will: </strong>Displaying a cached data-uri ttf/otf/woff</li>
<li><strong>Will not: </strong>Displaying a font that is already installed and named in your traditional font stack</li>
<li><strong>Will not: </strong>Displaying a font that is installed and named using the local() location</li>
</ul>
<h4>Let&#039;s get the font ASAP</h4>
<p>The sooner the better, so let&#039;s prioritize getting this font before everything else.</p>
<p>We&#039;ll set up our @font-face declaration:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">    <span style="color: #808080; font-style: italic;">/* chunk will load immediately in IE at this declaration*/</span>
    <span style="color: #a1a100;">@font-face {</span>
    	<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> <span style="color: #ff0000;">'ChunkFive Regular'</span><span style="color: #00AA00;">;</span>
    	src<span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'fonts/Chunkfive.eot'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
    	src<span style="color: #00AA00;">:</span> local<span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'ChunkFive Regular'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span> local<span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'ChunkFive-Regular'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'fonts/Chunkfive.otf'</span><span style="color: #00AA00;">&#41;</span> format<span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'opentype'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
    <span style="color: #00AA00;">&#125;</span>
    <span style="color: #808080; font-style: italic;">/* define a class that uses this font */</span>
    <span style="color: #6666ff;">.chunk</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span><span style="color: #ff0000;">'ChunkFive Regular'</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>And inside the <code>&lt;head&gt;</code>, we&#039;ll include this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>className<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">// quit early if we're in IE, no need to do any of this.</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #006600; font-style: italic;">/*@cc_on!@*/</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> f <span style="color: #339933;">=</span> document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'fontdl'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    f.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'fontdl'</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">// associate with the @font-face declaration and hide it</span>
    f.<span style="color: #660066;">className</span> <span style="color: #339933;">=</span> className<span style="color: #339933;">;</span>
    f.<span style="color: #660066;">style</span>.<span style="color: #660066;">cssText</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'position:absolute; visibility:hidden'</span>
    <span style="color: #006600; font-style: italic;">// it's still off-DOM so it doesn't download yet</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">// document.body doesnt exist yet so we'll add it onto the HTML tag</span>
    document.<span style="color: #660066;">documentElement</span>.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>f<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">// font download initiated Now.</span>
    <span style="color: #006600; font-style: italic;">// let's clean up after ourselves (opera needs a timeout &gt; 0)</span>
    setTimeout<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>f.<span style="color: #660066;">parentNode</span> <span style="color: #339933;">&amp;&amp;</span> f.<span style="color: #660066;">parentNode</span>.<span style="color: #660066;">removeChild</span><span style="color: #009900;">&#40;</span>f<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #CC0000;">100</span><span style="color: #009900;">&#41;</span>  
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'chunk'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// &lt;== pass in the class here.</span></pre></div></div>

<div class="update">2009.10.10: Based on a tip from my colleague <a href="http://blog.amodernfable.com/">Adam McIntyre</a>, we have a more elegant solution than the above javascript. It, along with more fontstack research, is as follows&#8230;</div>
<p>Rather than creating an element on the fly that uses the font, we do the same with HTML:<br />
Adam postulated the we could do the same trick by classing the HTML tag:<br />
(e.g. <code>&lt;html class="chunk"&gt;</code>)</p>
<ul>
<li>The font-family style won&#039;t actually cascade, so no worries about it being inherited by your content</li>
<li>This works in Gecko and Opera, but not Webkit</li>
</ul>
<p>Alternatively, we add an applicable element to the head:<br />
<code>&lt;b class="chunk" style="position:absolute; visibility:hidden">download please&lt;/b></code></p>
<ul>
<li>Works in webkit, gecko, opera. Waa hoo!</li>
<li>Obviously this doesn&#039;t validate. FYI, The element will be thrown into the &lt;body> on page load. </li>
</ul>
<h4>Can I pre-load all the font assets?</h4>
<p>So let&#039;s say we have more than one @font-face declaration:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #a1a100;">@font-face { font-family: 'ChunkFive Regular'; src: local('ChunkFive Regular'), url('fonts/Chunkfive.otf') format('opentype'); }</span>
&nbsp;
<span style="color: #a1a100;">@font-face { font-family: 'League Gothic'; src: local('league gothic'), url('fonts/LeagueGothic.otf') format('opentype'); }</span></pre></div></div>

<p>If we set a new class that references both new fonts in a single fontstack, and then pass use that class for our above techniques:</p>
<ul>
<li>Gecko retrieves all webfonts mentioned in the font stack.</li>
<li>Opera retrieves all webfonts mentioned in the font stack.</li>
<li>IE, as mentioned, retrieves them when they&#039;re declared, not used.</li>
<li>Webkit retrieves each font mentioned sequentially until it finds a working one.
<ul>
<li>404s and invalid files are considered non-working, of couse.</li>
</ul>
</li>
</ul>
<p>So with some CSS like so:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">    <span style="color: #6666ff;">.chunk</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span><span style="color: #ff0000;">'ChunkFive Regular'</span><span style="color: #00AA00;">&#125;</span>
    <span style="color: #6666ff;">.league</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span><span style="color: #ff0000;">'League Gothic'</span><span style="color: #00AA00;">&#125;</span>
    <span style="color: #6666ff;">.allfonts</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> <span style="color: #ff0000;">'ChunkFive Regular'</span><span style="color: #00AA00;">,</span> <span style="color: #ff0000;">'League Gothic'</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!-- preloads both fonts in gecko and opera, webkit only gets the first --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">b</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;allfonts&quot;</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;position:absolute; visibility:hidden&quot;</span>&gt;</span>download please<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">b</span>&gt;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- preloads all the fonts in the fontstack in gecko, opera, and webkit --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">b</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;chunk&quot;</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;position:absolute; visibility:hidden&quot;</span>&gt;</span>download please<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">b</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">b</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;league&quot;</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;position:absolute; visibility:hidden&quot;</span>&gt;</span>download please<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">b</span>&gt;</span></pre></div></div>

<h4>Is this the end-all be-all solution to quick load and FOUT?</h4>
<p>Nope. As Jonathan Snook pointed out in the comments, these won&#039;t elimate seeing the fallback font FOUT in Gecko and Opera, they only prioritize the load of those fonts. As we know, <a href="http://www.stevesouders.com/blog/2008/03/20/roundup-on-parallel-connections/">browsers have a limit of concurrent connections</a>, so we&#039;re using these tricks to get the fonts first in line. </p>
<p>Also, This is really only for the initial time, because after that, your far-futures expire header means the ttf stays cached locally, no more requests needed.</p>
<p>I&#039;m not sure if we&#039;ll be able to use webkit&#039;s transparent font load in Gecko in any graceful way. <small>(It&#039;s possible with a sniff and polling, but that seems like overkill)</small> I&#039;m also not sure if we&#039;ll get Gecko&#039;s load technique in Webkit, which would be optimal for slow/mobile connections. For the time being your time is best served getting the font size very small, <a href="http://www.phpied.com/gzip-your-font-face-files/">gzipping</a> it, prioritizing it first, and caching it for a while.</p>
<h4 id="defeatthefout">Defeat the Firefox FOUT entirely</h4>
<p>A little bit ago, <a href="http://www.typotheque.com/webfonts/FOUC">Typotheque posted a technique</a> aiming to avoid the FOUT. Using jQuery, they hide the <code>body</code> on dom ready, and then reveal it at the window load event. </p>
<p>The posted technique doesn&#039;t work as:</p>
<ul>
<li>It targets all users, but we should only tweaks things for Firefox 3.5+ users.</li>
<li>Users will actually see the text before it&#039;s hidden during at dom ready.</li>
<li>As was mentioned earlier, fonts are downloaded when text appears in the page that the font will apply to. Therefore, anything hidden with <code>display:none</code> will not request the font file.</li>
<li>Not everyone has jQuery, so let&#039;s go with something more general</li>
</ul>
<p>The one serious caveat to this technique is: <strong>The page will not be visible <del>until all content, iframes, remote scripts, fonts, <em>and images</em> are downloaded.</del><ins> for a maximum of three seconds</ins></strong> (I added a three second bailout condition, read below.)</p>
<p>This should run in the <code>&lt;head&gt;</code> somwhere:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #006600; font-style: italic;">// if firefox 3.5+, hide content till load (or 3 seconds) to prevent FOUT</span>
  <span style="color: #003366; font-weight: bold;">var</span> d <span style="color: #339933;">=</span> document<span style="color: #339933;">,</span> e <span style="color: #339933;">=</span> d.<span style="color: #660066;">documentElement</span><span style="color: #339933;">,</span> s <span style="color: #339933;">=</span> d.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'style'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #660066;">style</span>.<span style="color: #660066;">MozTransform</span> <span style="color: #339933;">===</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">// gecko 1.9.1 inference</span>
    s.<span style="color: #660066;">textContent</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'body{visibility:hidden}'</span><span style="color: #339933;">;</span>
    e.<span style="color: #660066;">firstChild</span>.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">function</span> f<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> s.<span style="color: #660066;">parentNode</span> <span style="color: #339933;">&amp;&amp;</span> s.<span style="color: #660066;">parentNode</span>.<span style="color: #660066;">removeChild</span><span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
    addEventListener<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'load'</span><span style="color: #339933;">,</span>f<span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    setTimeout<span style="color: #009900;">&#40;</span>f<span style="color: #339933;">,</span><span style="color: #CC0000;">3000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>First, we are detecting if we&#039;re firefox 3.5+ by seeing if -moz-transform is supported, which was added at the same time.  We use visibility:hidden instead of display:none, so that the font will actually be requested, and we remove that style once the page has finished loading. We&#039;re hinging on window load to be our re-entry point, because as <a href="http://www.stevesouders.com/blog/2009/10/13/font-face-and-performance/">Steve Souders pointed out</a>, &#034;font files block the window’s onload event from firing in IE and Firefox, but not Safari nor Chrome.&#034;  </p>
<p>I&#039;ve also added a 3 second bailout condition; this means if the page has not completely loaded in three seconds, we&#039;re going to show it anyway. It&#039;s <em>possible</em> the font won&#039;t be ready, but unlikely, I believe. This aims to solve <a href="http://remysharp.com/2009/06/23/safaris-problem-with-font-face/">the issue Remy found</a> with the Standards.next site. I wouldn&#039;t recommend it, but you can disable this behavior by commenting out the setTimeout line.</p>
<div class="update">2009.11.07. Added the <em>Defeat the Firefox FOUT</em> section.</p>
<p>2009.11.08. Tweaked defeat FOUT code to have a 3 second bailout.</p>
<p>2009.12.14. Added the <em>In what cases will you get a FOUT</em> section.</div>
]]></content:encoded>
			<wfw:commentRss>http://paulirish.com/2009/fighting-the-font-face-fout/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Chrome and @font-face: It&#039;s here!</title>
		<link>http://paulirish.com/2009/chrome-and-font-face-a-summary/</link>
		<comments>http://paulirish.com/2009/chrome-and-font-face-a-summary/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 16:59:10 +0000</pubDate>
		<dc:creator>Paul Irish</dc:creator>
		
		<category><![CDATA[front-end development]]></category>

		<category><![CDATA[typography]]></category>

		<guid isPermaLink="false">http://paulirish.com/?p=421</guid>
		<description><![CDATA[January 25, 2010: It is now in the stable Chrome release! The wait is over, everyone. :) [release notes]

Today, Zeldman issued an ultimatum that we&#039;ve all been feeling recently:

It&#039;s true, every major browser supports @font-face:

Internet Explorer: since IE5
Firefox: since FF3.5
Safari: since Safari 3.2
Opera: since Opera 10

But..
Google Chrome currently does not enable @font-face linking to ttf [...]]]></description>
			<content:encoded><![CDATA[<div class="update">January 25, 2010: It is now in the stable Chrome release! The wait is over, everyone. :) [<a href="http://googlechromereleases.blogspot.com/2010/01/stable-channel-update_25.html">release notes</a>]</p>
<p><a href="http://googlechromereleases.blogspot.com/2010/01/stable-channel-update_25.html"><img src="http://paulirish.com/i/fontfacesupportedinchrome.png"></a></div>
<p>Today, <a href="http://www.zeldman.com">Zeldman</a> issued an ultimatum that we&#039;ve all been feeling recently:<br />
<a href="http://twitter.com/zeldman/statuses/4371468319" ><img src="http://paulirish.com/wp-content/uploads/2009/09/607cd0c8d4098b2fac2b2da85bbfc4b8.png" alt="Chrome needs to support @font-face immediately."width="550" class="alignnone size-full wp-image-422" /></a></p>
<p>It&#039;s true, every major browser supports @font-face:</p>
<ul>
<li>Internet Explorer: since IE5</li>
<li>Firefox: since FF3.5</li>
<li>Safari: since Safari 3.2</li>
<li>Opera: since Opera 10</li>
</ul>
<p>But..<br />
<strong>Google Chrome currently does not enable @font-face linking to ttf and otf. </strong></p>
<p><small>It actually does support SVG fonts in a @font-face declaration. <a href="http://devfiles.myopera.com/articles/593/SVGfonts_in_HTML.html">View this demo in Chrome or Chromium to see svg fonts in action.</a> Divya has some <a href="http://nimbupani.com/blog/about-fonts-in-svg.html">great research around fonts and SVG</a> if you&#039;re interested in more.</small></p>
<h4>You can turn it on, at will</h4>
<p>You can enable web fonts with an executable switch: <tt>&minus;&minus;enable-remote-fonts</tt>.
</p>
<p>On Windows, you can <a href="http://paulirish.com/wp-content/uploads/2009/09/chrome-exe-remote-fonts-switch.png">tweak the shortcut path, like so</a>.<br />
With Chromium on OS X, you use Terminal to launch:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">/Applications/Chromium.app/Contents/MacOS/Chromium --enable-remote-fonts</pre></div></div>

<p>With proper Google Chrome on OS X, you need to escape the spaces:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --enable-remote-fonts</pre></div></div>

<p>With Chromium on Linux<sup><a href="http://lyncis.info/uk/post/267">[1]</a></sup>:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">chromium-browser --enable-plugins --enable-remote-fonts %U</pre></div></div>

<p>Once you enable it, all @font-face stuff works just as you&#039;d expect, including the <a href="http://paulirish.com/2009/bulletproof-font-face-implementation-syntax/">bulletproof @font-face syntax</a> [<a href="http://dl.getdropbox.com/u/39519/webfontsdemo/index.html">demo</a>] and the <a href="http://nicewebtype.com/fonts/">Nice Web Type demos</a>.</p>
<h4>But we need web fonts working by default</h4>
<p><em>Wait, so why is this wonderful feature disabled by default? </em>Security review. Ian Fette, the program manager of Chrome, <a href="http://groups.google.com/group/chromium-dev/browse_thread/thread/c3b3db4339d3642c/c0040c5d39cfa1db#msg_2906e49b84377501">indicated that they need to explore</a> how do webfonts in a &#034;reasonably safe manner&#034;. So that&#039;s the holdup.<br />
<a href="http://code.google.com/p/chromium/issues/detail?id=17818">This ticket on the Chromium bug tracker</a> tracks the feature being enabled by default.</p>
<h4>Okay, so when do we get our toy? Soon, in fact!</h4>
<p>Chrome is my default browser, so my patience on this issue ran dry recently. I emailed Takuya, an engineer at Google Japan, who is working on this and he said:</p>
<blockquote><p>We are almost done. The code is under review internally within Google. I&#039;m expecting to make it public no later than a week or so.</p></blockquote>
<p>So I expect we&#039;ll be seeing @font-face support enabled by default in the Chrome dev builds soon. Based on their release schedule I think it&#039;ll be near the end of the year when we see it in Chrome stable. That&#039;s good news; let&#039;s hope we see it sooner.</p>
<div class="update" id="update"><a name="update"></a>2009.10.19 : The ticket tracking @font-face on by default <a href="http://code.google.com/p/chromium/issues/detail?id=17818#c12">gained the Milestone-4 label</a>, indicating it will be included in Chrome 4 Stable.</p>
<p>
<span id="20091104">2009.11.04</a>: The Chromium team has released <a href="http://code.google.com/p/ots/">ots - an OpenType sanitizer library</a> meant to clean any security concerns from a font file included via @font-face. They have also <a href="https://bugs.webkit.org/show_bug.cgi?id=31106">filed a bug upstream</a> with WebKit to integrate this code at the Webkit level. Finally we see the fruit of their security review.</p>
<p>2009.11.18: Remote fonts are now <a href="http://code.google.com/p/chromium/issues/detail?id=17818#c18">enabled by default</a>!!! This should only be in the dev builds for now. I&#039;ll update when it makes it to beta builds and eventually the stable. But right now it still looks like we&#039;ll see this in version 4 stable. <em>(Nov 21: confirmed its in dev builds.. starting with version 4.0.249.4 [<a href="http://googlechromereleases.blogspot.com/2009/11/dev-channel-update_20.html">blog post</a>], [<a href="http://build.chromium.org/buildbot/perf/dashboard/ui/changelog.html?url=/branches/249/src&#038;range=32060:32530&#038;mode=html">rev 32300</a>])</em></p>
<p>2009.12.09: @font-face support is now in the Chrome Beta of both Windows and Mac.</p>
<p>2010.01.25: @font-face support is now in the Windows Chrome Stable release! [<a href="http://googlechromereleases.blogspot.com/2010/01/stable-channel-update_25.html">release notes</a>]
</div>
]]></content:encoded>
			<wfw:commentRss>http://paulirish.com/2009/chrome-and-font-face-a-summary/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Avoiding the FOUC v3.0</title>
		<link>http://paulirish.com/2009/avoiding-the-fouc-v3/</link>
		<comments>http://paulirish.com/2009/avoiding-the-fouc-v3/#comments</comments>
		<pubDate>Wed, 23 Sep 2009 16:04:17 +0000</pubDate>
		<dc:creator>Paul Irish</dc:creator>
		
		<category><![CDATA[front-end development]]></category>

		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://paulirish.com/?p=411</guid>
		<description><![CDATA[FOUC is an unwelcome guest to your soirée of intertube funtimes. He comes in and distracts users eyes with things they shouldn&#039;t be seeing, and then departs ever so quickly. We don&#039;t like him.
So you&#039;ve likely seen code like this:

&#60;body&#62;
  &#60;script&#62;document.body.className += 'js';&#60;/script&#62;

No good. Scripts in the body block rendering so we can do [...]]]></description>
			<content:encoded><![CDATA[<p><abbr title="Flash of unstyled content">FOUC</abbr> is an unwelcome guest to your soirée of intertube funtimes. He comes in and distracts users eyes with things they shouldn&#039;t be seeing, and then departs ever so quickly. We don&#039;t like him.</p>
<p>So you&#039;ve likely seen code like this:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span>&gt;</span>document.body.className += 'js';<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></div></div>

<p>No good. Scripts in the body block rendering so we can do better<sup><a href="http://www.learningjquery.com/2008/10/1-way-to-avoid-the-flash-of-unstyled-content">[1]</a></sup>:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span>&gt;</span>document.documentElement.className += 'js';<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></div></div>

<p>Here we&#039;ll be adding the class to the HTML element instead of the body, which we have access while we&#039;re in the HEAD. (Naturally CSS works just fine with a html.js selector, though this doesn&#039;t validate in HTML4)</p>
<p>But here&#039;s my big hang-up:<br />
<b>I prefer to write unique css for the no-javascript user.</b> I don&#039;t want to be writing .js in front of every selector for my basic accordion/carousel/etc widgets. It&#039;s terribly tedious. I really just want a .no-js hook.</p>
<p>My solution:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;no-js&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span>&gt;</span>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></div></div>

<p>The markup has a no-js class on HTML by default but we&#039;ll very safely change that to &#039;js&#039; inside the head.  That compressed line of javascript is basically:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">document.<span style="color: #660066;">documentElement</span>.<span style="color: #660066;">className</span> <span style="color: #339933;">=</span> document.<span style="color: #660066;">documentElement</span>.<span style="color: #660066;">className</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\bno-js\b/</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>But I make it small as it&#039;s one of the only scripts that should run in your head. Because everyone has their scripts near their &lt;/body&gt; tag, right?</p>
<p>We use the same approach in <a href="http://www.modernizr.com">Modernizr</a>, because we want the classes to be all set on the HTML element right when the BODY content starts loading in. Fight the FOUC!</p>
]]></content:encoded>
			<wfw:commentRss>http://paulirish.com/2009/avoiding-the-fouc-v3/feed/</wfw:commentRss>
		</item>
		<item>
		<title>jQuery Conference 2009</title>
		<link>http://paulirish.com/2009/jquery-conference-2009/</link>
		<comments>http://paulirish.com/2009/jquery-conference-2009/#comments</comments>
		<pubDate>Sun, 13 Sep 2009 15:20:41 +0000</pubDate>
		<dc:creator>Paul Irish</dc:creator>
		
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://paulirish.com/?p=389</guid>
		<description><![CDATA[Currently rounding up the last day of #jqcon and it&#039;s one of the best events I&#039;ve been too. Crazy to see jQuery&#039;s annual meetup double in size each year and scale with talent and organization just as nicely.  I somehow tricked the attendees into voting two talk proposals up (thanks!), so I got to [...]]]></description>
			<content:encoded><![CDATA[<p>Currently rounding up the last day of #jqcon and it&#039;s one of the best events I&#039;ve been too. Crazy to see jQuery&#039;s annual meetup double in size each year and scale with talent and organization just as nicely.  I somehow tricked the attendees into voting two talk proposals up (thanks!), so I got to discuss two things this weekend. </p>
<p><img src="http://paulirish.com/wp-content/uploads/2009/09/pic_gew_l.jpg" title="Giving my Anti-Patterns talk. cameraphone pic by Rey Bango"></p>
<p>I&#039;d love to any feedback you may have and plan to write on these topics in more detail, but for now.. my slides:</p>
<p><a href="http://paulirish.com/2009/perf/">jQuery Anti-Patterns for Performance &amp; Compression</a></p>
<p><a href="http://paulirish.com/2009/customfonts/">Employing Custom Fonts&#8230; Now!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://paulirish.com/2009/jquery-conference-2009/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Employing Custom Fonts… Now!</title>
		<link>http://paulirish.com/2009/customfonts/</link>
		<comments>http://paulirish.com/2009/customfonts/#comments</comments>
		<pubDate>Sun, 13 Sep 2009 15:08:23 +0000</pubDate>
		<dc:creator>Paul Irish</dc:creator>
		
		<category><![CDATA[typography]]></category>

		<guid isPermaLink="false">http://paulirish.com/?page_id=387</guid>
		<description><![CDATA[Employing Custom Fonts
View more presentations from Paul Irish.

]]></description>
			<content:encoded><![CDATA[<div style="width:425px;text-align:left" id="__ss_1991319"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" href="http://www.slideshare.net/paul.irish/employingcustomfonts-other-look" title="Employing Custom Fonts">Employing Custom Fonts</a><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=employingcustomfontsotherlook-090913094507-phpapp01&#038;stripped_title=employingcustomfonts-other-look" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=employingcustomfontsotherlook-090913094507-phpapp01&#038;stripped_title=employingcustomfonts-other-look" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object>
<div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;">View more <a style="text-decoration:underline;" href="http://www.slideshare.net/">presentations</a> from <a style="text-decoration:underline;" href="http://www.slideshare.net/paul.irish">Paul Irish</a>.</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://paulirish.com/2009/customfonts/feed/</wfw:commentRss>
		</item>
		<item>
		<title>jQuery Anti-Patterns for Performance</title>
		<link>http://paulirish.com/2009/perf/</link>
		<comments>http://paulirish.com/2009/perf/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 22:42:01 +0000</pubDate>
		<dc:creator>Paul Irish</dc:creator>
		
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://paulirish.com/?page_id=379</guid>
		<description><![CDATA[jQuery Anti-Patterns for Performance &#38; Compression
View more presentations from Paul Irish.

]]></description>
			<content:encoded><![CDATA[<div style="width:425px;text-align:left" id="__ss_1984008"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" href="http://www.slideshare.net/paul.irish/perfcompression" title="jQuery Anti-Patterns for Performance &amp; Compression">jQuery Anti-Patterns for Performance &amp; Compression</a><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=perfcompression-090911091939-phpapp01&#038;stripped_title=perfcompression" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=perfcompression-090911091939-phpapp01&#038;stripped_title=perfcompression" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object>
<div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;">View more <a style="text-decoration:underline;" href="http://www.slideshare.net/">presentations</a> from <a style="text-decoration:underline;" href="http://www.slideshare.net/paul.irish">Paul Irish</a>.</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://paulirish.com/2009/perf/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 6.165 seconds -->
<!-- Cached page generated by WP-Super-Cache on 2010-03-10 15:22:35 -->
