<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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>Comments on: Detecting Support for data: URIs</title>
	<atom:link href="http://weston.ruter.net/2009/05/07/detecting-support-for-data-uris/feed/" rel="self" type="application/rss+xml" />
	<link>http://weston.ruter.net/2009/05/07/detecting-support-for-data-uris/</link>
	<description>Web application developer in Portland, Oregon</description>
	<lastBuildDate>Fri, 09 Dec 2011 18:07:07 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
	<item>
		<title>By: PVHL (Paul)</title>
		<link>http://weston.ruter.net/2009/05/07/detecting-support-for-data-uris/comment-page-1/#comment-29924</link>
		<dc:creator>PVHL (Paul)</dc:creator>
		<pubDate>Sun, 05 Jun 2011 23:20:08 +0000</pubDate>
		<guid isPermaLink="false">http://weston.ruter.net/?p=162#comment-29924</guid>
		<description>Absolutely. You&#039;re overlooking that a) I wasn&#039;t paying enough attention, and b) I wasn&#039;t paying enough attention. Right. Already downloaded with the CSS ... my apologies. Where&#039;s the delete button when you need it?

Anyway, I applied your method to simply turning on/off text and images in IE6/7 and it worked well, but I thought it was easier with the two class possibilities. (Obviously, star hack accomplishes this too, but I was looking for a more elegant and standards compliant method.) Going back now and looking at it again I see that only one is ever needed, and as you say, in a scripting disabled scenario this would be much better (my application is for a javascript required application). Long day? Senility? Was I awake? I don&#039;t know.

Still, it did get me to check out your other work and discover OpenScripture which I look forward to looking into further.

Thanks for the feedback.</description>
		<content:encoded><![CDATA[<p>Absolutely. You&#8217;re overlooking that a) I wasn&#8217;t paying enough attention, and b) I wasn&#8217;t paying enough attention. Right. Already downloaded with the CSS &#8230; my apologies. Where&#8217;s the delete button when you need it?</p>
<p>Anyway, I applied your method to simply turning on/off text and images in IE6/7 and it worked well, but I thought it was easier with the two class possibilities. (Obviously, star hack accomplishes this too, but I was looking for a more elegant and standards compliant method.) Going back now and looking at it again I see that only one is ever needed, and as you say, in a scripting disabled scenario this would be much better (my application is for a javascript required application). Long day? Senility? Was I awake? I don&#8217;t know.</p>
<p>Still, it did get me to check out your other work and discover OpenScripture which I look forward to looking into further.</p>
<p>Thanks for the feedback.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Weston Ruter</title>
		<link>http://weston.ruter.net/2009/05/07/detecting-support-for-data-uris/comment-page-1/#comment-29884</link>
		<dc:creator>Weston Ruter</dc:creator>
		<pubDate>Sun, 05 Jun 2011 04:46:36 +0000</pubDate>
		<guid isPermaLink="false">http://weston.ruter.net/?p=162#comment-29884</guid>
		<description>@PVHL:
Thanks for the feedback, especially with the finding that the smaller GIF provided by Mathias doesn&#039;t work in IE9.

&lt;blockquote&gt;Bit surprised by the “that’s the price you pay for using an old browser”. Why not add an “else”?&lt;/blockquote&gt;

I don&#039;t see the benefit in your code over mine as far as the price of having to download the image twice if using a browser that doesn&#039;t support &lt;code&gt;data:&lt;/code&gt; URLs. In both of our code, the Base64 image is downloaded along with the stylesheet regardless if the browser can use it, and in both cases the non-supporting browser will have to download the fallback separately. So isn&#039;t the result the same? And actually, I think your code results in an even more undesirable situation: it requires that the user have scripting enabled in order to see any background image at all. In mine, the only case where they wouldn&#039;t see a background image is if they are using a non-supporting browser &lt;em&gt;and&lt;/em&gt; they have scripting turned off. But with your code, they won&#039;t see a background image in &lt;em&gt;any&lt;/em&gt; browser that has scripting disabled.

Am I overlooking something? Thanks!</description>
		<content:encoded><![CDATA[<p>@PVHL:<br />
Thanks for the feedback, especially with the finding that the smaller GIF provided by Mathias doesn&#8217;t work in IE9.</p>
<blockquote><p>Bit surprised by the “that’s the price you pay for using an old browser”. Why not add an “else”?</p></blockquote>
<p>I don&#8217;t see the benefit in your code over mine as far as the price of having to download the image twice if using a browser that doesn&#8217;t support <code>data:</code> URLs. In both of our code, the Base64 image is downloaded along with the stylesheet regardless if the browser can use it, and in both cases the non-supporting browser will have to download the fallback separately. So isn&#8217;t the result the same? And actually, I think your code results in an even more undesirable situation: it requires that the user have scripting enabled in order to see any background image at all. In mine, the only case where they wouldn&#8217;t see a background image is if they are using a non-supporting browser <em>and</em> they have scripting turned off. But with your code, they won&#8217;t see a background image in <em>any</em> browser that has scripting disabled.</p>
<p>Am I overlooking something? Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: PVHL (Paul)</title>
		<link>http://weston.ruter.net/2009/05/07/detecting-support-for-data-uris/comment-page-1/#comment-29861</link>
		<dc:creator>PVHL (Paul)</dc:creator>
		<pubDate>Sat, 04 Jun 2011 19:58:00 +0000</pubDate>
		<guid isPermaLink="false">http://weston.ruter.net/?p=162#comment-29861</guid>
		<description>Bit surprised by the &quot;that’s the price you pay for using an old browser&quot;. Why not add an &quot;else&quot;?
&lt;pre&gt;&lt;code&gt;var data = new Image();
data.onload = data.onerror = function(){
	if(this.width != 1 &#124;&#124; this.height != 1)
		document.documentElement.className += &quot; no-data-uri&quot;;
	else
		document.documentElement.className += &quot; data-uri&quot;;
}
data.src = &quot;data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==&quot;;&lt;/code&gt;&lt;/pre&gt;
And the corresponding rule update:
&lt;pre&gt;&lt;code&gt;html.data-uri #foo {
    background-image:url(&quot;data:image/png;base64,...&quot;);
}
html.no-data-uri #foo {
    background-image:url(&quot;images/foo.png&quot;); /* fallback */
}&lt;/code&gt;&lt;/pre&gt;
Now each does what it should, and no-one is penalized (assuming the same loading behaviour as described in the post, I haven&#039;t checked it yet).

BTW, I have found that IE, including 9, has inconsistent behaviour with data uris. If used for an image the block of data can be formatted into lines using &quot;\&quot;, but if used for background images the load will fail. Another browser did this too ... looks like we have to make it a single line to be cross-browser; could this be the reason for IE&#039;s small data uri length limit?

Also, I couldn&#039;t get the smaller image mentioned in the comments to load in IE9, though it worked in Firefox; it caused onerror to trigger with strange width and height.

Nice article. Thanks. (Just what I was looking for =)</description>
		<content:encoded><![CDATA[<p>Bit surprised by the &#8220;that’s the price you pay for using an old browser&#8221;. Why not add an &#8220;else&#8221;?</p>
<pre><code>var data = new Image();
data.onload = data.onerror = function(){
	if(this.width != 1 || this.height != 1)
		document.documentElement.className += " no-data-uri";
	else
		document.documentElement.className += " data-uri";
}
data.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";</code></pre>
<p>And the corresponding rule update:</p>
<pre><code>html.data-uri #foo {
    background-image:url("data:image/png;base64,...");
}
html.no-data-uri #foo {
    background-image:url("images/foo.png"); /* fallback */
}</code></pre>
<p>Now each does what it should, and no-one is penalized (assuming the same loading behaviour as described in the post, I haven&#8217;t checked it yet).</p>
<p>BTW, I have found that IE, including 9, has inconsistent behaviour with data uris. If used for an image the block of data can be formatted into lines using &#8220;\&#8221;, but if used for background images the load will fail. Another browser did this too &#8230; looks like we have to make it a single line to be cross-browser; could this be the reason for IE&#8217;s small data uri length limit?</p>
<p>Also, I couldn&#8217;t get the smaller image mentioned in the comments to load in IE9, though it worked in Firefox; it caused onerror to trigger with strange width and height.</p>
<p>Nice article. Thanks. (Just what I was looking for =)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Data URIs and Automation with CSSEmbed and Ant &#171; Phil Mander&#039;s Tech Blog</title>
		<link>http://weston.ruter.net/2009/05/07/detecting-support-for-data-uris/comment-page-1/#comment-21781</link>
		<dc:creator>Data URIs and Automation with CSSEmbed and Ant &#171; Phil Mander&#039;s Tech Blog</dc:creator>
		<pubDate>Mon, 22 Nov 2010 20:12:39 +0000</pubDate>
		<guid isPermaLink="false">http://weston.ruter.net/?p=162#comment-21781</guid>
		<description>[...] If you&#8217;re concerned about any browsers out there which aren&#8217;t IE &lt; 8 and don&#8217;t support data URIs, take a look at the following progressive enhancement technique using Javascript (adapted from here). [...]</description>
		<content:encoded><![CDATA[<p>[...] If you&#8217;re concerned about any browsers out there which aren&#8217;t IE &lt; 8 and don&#8217;t support data URIs, take a look at the following progressive enhancement technique using Javascript (adapted from here). [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mathias Bynens</title>
		<link>http://weston.ruter.net/2009/05/07/detecting-support-for-data-uris/comment-page-1/#comment-20909</link>
		<dc:creator>Mathias Bynens</dc:creator>
		<pubDate>Tue, 26 Oct 2010 11:17:26 +0000</pubDate>
		<guid isPermaLink="false">http://weston.ruter.net/?p=162#comment-20909</guid>
		<description>You could save some bytes by using &lt;a href=&quot;http://probablyprogramming.com/2009/03/15/the-tiniest-gif-ever/&quot; rel=&quot;nofollow&quot;&gt;the tiniest GIF image ever&lt;/a&gt; (26 bytes): &lt;code&gt;data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>You could save some bytes by using <a href="http://probablyprogramming.com/2009/03/15/the-tiniest-gif-ever/" rel="nofollow">the tiniest GIF image ever</a> (26 bytes): <code>data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jpv</title>
		<link>http://weston.ruter.net/2009/05/07/detecting-support-for-data-uris/comment-page-1/#comment-11464</link>
		<dc:creator>jpv</dc:creator>
		<pubDate>Tue, 01 Dec 2009 12:43:06 +0000</pubDate>
		<guid isPermaLink="false">http://weston.ruter.net/?p=162#comment-11464</guid>
		<description>Nice trick, however have you tried to find a way to detect the support non-asynchronously ?

I tried to use this technique not for css specifically but in conjonction with XHR progress event in order to display a real progress bar when loading heavy images (see my post in french, but code is readable : http://jpv.typepad.com/blog/2009/11/barre-de-chargement-dune-image.html)

However due to the various limitations of the browser around the length of data you can put in an URL, you can not load huge images (around 1Mo)
So this technique really should be confined to CSS images</description>
		<content:encoded><![CDATA[<p>Nice trick, however have you tried to find a way to detect the support non-asynchronously ?</p>
<p>I tried to use this technique not for css specifically but in conjonction with XHR progress event in order to display a real progress bar when loading heavy images (see my post in french, but code is readable : <a href="http://jpv.typepad.com/blog/2009/11/barre-de-chargement-dune-image.html" rel="nofollow">http://jpv.typepad.com/blog/2009/11/barre-de-chargement-dune-image.html</a>)</p>
<p>However due to the various limitations of the browser around the length of data you can put in an URL, you can not load huge images (around 1Mo)<br />
So this technique really should be confined to CSS images</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rich</title>
		<link>http://weston.ruter.net/2009/05/07/detecting-support-for-data-uris/comment-page-1/#comment-11061</link>
		<dc:creator>Rich</dc:creator>
		<pubDate>Fri, 20 Nov 2009 21:02:25 +0000</pubDate>
		<guid isPermaLink="false">http://weston.ruter.net/?p=162#comment-11061</guid>
		<description>That&#039;s a very good point - I&#039;d only really thought of them as inline for some reason. I agree, in fact, having thought about it more, almost any small image would be best served in this way.</description>
		<content:encoded><![CDATA[<p>That&#8217;s a very good point &#8211; I&#8217;d only really thought of them as inline for some reason. I agree, in fact, having thought about it more, almost any small image would be best served in this way.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Weston Ruter</title>
		<link>http://weston.ruter.net/2009/05/07/detecting-support-for-data-uris/comment-page-1/#comment-10864</link>
		<dc:creator>Weston Ruter</dc:creator>
		<pubDate>Sun, 15 Nov 2009 15:30:54 +0000</pubDate>
		<guid isPermaLink="false">http://weston.ruter.net/?p=162#comment-10864</guid>
		<description>@Rich:
I think they are useful inline if the images are small enough (i.e. a rounded corner) where there is an acceptable cost/benefit ratio of HTTP request count vs. page display time. But also I think that &lt;code&gt;data:&lt;/code&gt; URIs make the most sense in stylesheets. Actually, &lt;code&gt;data:&lt;/code&gt; URIs in stylesheets &lt;em&gt;are&lt;/em&gt; cached because the stylesheet itself should be cached. So when returning to the page, the stylesheet is loaded from the cache and the &lt;code&gt;data:&lt;/code&gt; URIs are loaded directly from it.</description>
		<content:encoded><![CDATA[<p>@Rich:<br />
I think they are useful inline if the images are small enough (i.e. a rounded corner) where there is an acceptable cost/benefit ratio of HTTP request count vs. page display time. But also I think that <code>data:</code> URIs make the most sense in stylesheets. Actually, <code>data:</code> URIs in stylesheets <em>are</em> cached because the stylesheet itself should be cached. So when returning to the page, the stylesheet is loaded from the cache and the <code>data:</code> URIs are loaded directly from it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: RIch</title>
		<link>http://weston.ruter.net/2009/05/07/detecting-support-for-data-uris/comment-page-1/#comment-10856</link>
		<dc:creator>RIch</dc:creator>
		<pubDate>Sun, 15 Nov 2009 10:42:16 +0000</pubDate>
		<guid isPermaLink="false">http://weston.ruter.net/?p=162#comment-10856</guid>
		<description>My only issue with data uris is that it means the image won&#039;t be cached, which is normally what you want. When would using an embedded image be a better idea?

It&#039;s very rare that an image will be requested only once.</description>
		<content:encoded><![CDATA[<p>My only issue with data uris is that it means the image won&#8217;t be cached, which is normally what you want. When would using an embedded image be a better idea?</p>
<p>It&#8217;s very rare that an image will be requested only once.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ajaxian &#187; CSS Gradients for All!</title>
		<link>http://weston.ruter.net/2009/05/07/detecting-support-for-data-uris/comment-page-1/#comment-7499</link>
		<dc:creator>Ajaxian &#187; CSS Gradients for All!</dc:creator>
		<pubDate>Tue, 28 Jul 2009 10:34:26 +0000</pubDate>
		<guid isPermaLink="false">http://weston.ruter.net/?p=162#comment-7499</guid>
		<description>[...] not support Canvas, although IE8 does support the data: URI scheme, which is a prerequisite (see support detection method). When/if Gears&#8217;s Canvas API fully implements the HTML5 canvas specification, then this [...]</description>
		<content:encoded><![CDATA[<p>[...] not support Canvas, although IE8 does support the data: URI scheme, which is a prerequisite (see support detection method). When/if Gears&#8217;s Canvas API fully implements the HTML5 canvas specification, then this [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

