<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.ravelrumba.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Ravelrumba</title>
	
	<link>http://www.ravelrumba.com</link>
	<description>web design &amp; web development</description>
	<lastBuildDate>Fri, 18 Jun 2010 16:49:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4245</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.ravelrumba.com/ravelrumba" /><feedburner:info uri="ravelrumba" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Data URIs and Dynamic Stylesheets</title>
		<link>http://feeds.ravelrumba.com/~r/ravelrumba/~3/SdxckyLIdy4/</link>
		<comments>http://www.ravelrumba.com/blog/data-uris-dynamic-stylesheet/#comments</comments>
		<pubDate>Thu, 17 Jun 2010 02:55:14 +0000</pubDate>
		<dc:creator>Rob Flaherty</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Web Performance]]></category>
		<category><![CDATA[Data URIs]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://www.ravelrumba.com/?p=825</guid>
		<description><![CDATA[This a quick follow-up to a post I wrote a few months ago about embedding data URIs in stylesheets and a potential performance hazard regarding the way non data URI images are positioned in the network waterfall.  What I found was that under certain circumstances the performance penalty was great enough to not only negate [...]]]></description>
			<content:encoded><![CDATA[<p>This a quick follow-up to a post I wrote a few months ago about <a href="/blog/data-uris-for-css-images-more-tests-more-questions/">embedding data URIs in stylesheets</a> and a potential performance hazard regarding the way non data URI images are positioned in the network waterfall.  What I found was that under certain circumstances the performance penalty was great enough to not only negate the benefits of using data URIs for images, but to actually increase the overall load time.</p>
<p>My solution was a hack: put the data URI images in a separate stylesheet and place the link to the stylesheet at the bottom of the page, after a script reference. This caused the browser to render the page after the main stylesheet (the one without the data URI images) and download the data URI stylesheet and other images in parallel.  The result was a fast loading, progressively rendered page.  But, in addition to producing invalid HTML, it went against the widely accepted best practice of keeping stylesheet references within the <code>head</code>.</p>
<p>Despite some <a href="/blog/data-uris-for-css-images-more-tests-more-questions/#comments">great discussion</a> in the comments, there didn&#8217;t seem to be a decent answer to the problem.  I forgot about it for a couple of months and then the other day the very obvious and simple solution came to me.</p>
<h5>A quick recap of the original obstacle</h5>
<p><img class="alignnone size-full wp-image-834" title="Version 1: dataURI images in main stylesheet" src="http://s.ravelrumba.com/uploads/2010/05/data-uri-waterfall-1.png" alt="Version 1: dataURI images in main stylesheet" width="600" height="160" /></p>
<p>When you replace the background image references in your stylesheet with data URIs, the size of your stylesheet increases significantly as the image bits are moved from image files into the stylesheet.  (After gzipping, the increase in stylesheet size equals the original size of the images.)  The page <em>weight</em> is the same but the difference is that stylesheets block rendering and downloading of images referenced in stylesheets.  This means the more data URI images you have in your stylesheet, the bigger your stylesheet, the longer it takes before the page is rendered, and the longer it takes before other non-data URI CSS images can be downloaded.  For an example, see how page components 4 and 5 are blocked in the above image.</p>
<p>You might be wondering why we would have both data URI CSS images and regular CSS images.  The reason is that IE8 only supports data URIs smaller than 32KB.  So if you have an image 32KB+ you&#8217;ll need to serve it normally if you want your site to get along with IE8.</p>
<h5>My previous hack/solution</h5>
<p><img class="alignnone size-full wp-image-840" title="Version 2: dataURI images in separate stylesheet in body" src="http://s.ravelrumba.com/uploads/2010/05/data-uri-waterfall-2.png" alt="Version 2: dataURI images in separate stylesheet in body" width="600" height="180" /><br />
One way I found to get around the problem was to move the data URI images into their own stylesheet (yes, adding an additional HTTP request) and force the browser to load the stylesheet asynchronously by placing the data URI stylesheet link in the <code>body</code>, after an external script reference.  As you can see in the waterfall, the data URI images and the regular images are now downloaded in parallel.</p>
<h5>A better way</h5>
<p><img class="alignnone size-full wp-image-911" title="dataURI waterfall using scripted link element" src="http://s.ravelrumba.com/uploads/2010/06/datauris-scripted-link.png" alt="dataURI waterfall using scripted link element" width="600" height="180" /><br />
Of course there&#8217;s a better way to achieve the same end.  All we need to do to get the parallel downloading we want is make the dataURI stylesheet load asynchronously, something we can easily do with Javascript.  Obviously the dataURI images will now be dependent on Javascript being enabled, so you&#8217;ll have to take that into consideration.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</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;">meta</span> <span style="color: #000066;">charset</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;utf-8&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>Title<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;style.css&quot;</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">media</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;all&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
        var datuURIs = document.createElement(&quot;link&quot;);
        document.head = document.head || document.getElementsByTagName('head')[0];
	datuURIs.href = &quot;duri-images.css&quot;;
	datuURIs.rel = &quot;stylesheet&quot;;
	document.head.appendChild(datuURIs);
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span></pre></div></div>

<p>Whether the dynamically inserted stylesheet occurs before or after the main stylesheet does not seem to matter in most browsers, but it does in IE8. In IE8 the dynamic stylesheet will block if it comes before the regular stylesheet. So if you&#8217;re using this technique you&#8217;ll want to order the elements as I have above.</p>
<p>On the general subject of using embedded data URIs for images, is it worth fussing with all this stuff?  In most cases I think the answer is probably not (yet, at least), in part because you can achieve a similar performance result with an aggressive use of CSS sprites.  Although CSS sprites have their own overheard and drawbacks, overall I think they&#8217;re easier to work with, especially when you start having to worry about data URI workarounds for IE6 and IE7.</p>
<p>But there are certainly situations where data URIs might be a good fit.  Mobile applications and &#8220;HTML5 apps&#8221; aimed at non-IE browsers come to mind.  And if nothing else, they&#8217;re fun to play with.</p>
<img src="http://feeds.feedburner.com/~r/ravelrumba/~4/SdxckyLIdy4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ravelrumba.com/blog/data-uris-dynamic-stylesheet/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.ravelrumba.com/blog/data-uris-dynamic-stylesheet/</feedburner:origLink></item>
		<item>
		<title>HTML5 Slideshow</title>
		<link>http://feeds.ravelrumba.com/~r/ravelrumba/~3/2Sx_-0DA9AU/</link>
		<comments>http://www.ravelrumba.com/blog/html5-slideshow/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 00:39:12 +0000</pubDate>
		<dc:creator>Rob Flaherty</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[slideshow]]></category>

		<guid isPermaLink="false">http://www.ravelrumba.com/?p=892</guid>
		<description><![CDATA[Maybe it&#8217;s because I have weak PowerPoint computer hacking skills, but whenever I work on a presentation I find myself thinking, &#8220;Shouldn&#8217;t this be easier?&#8221; or &#8220;I&#8217;d rather be doing this with CSS.&#8221;  So last week when I ran into my usual PowerPoint frustration I decided to devote a little time to correct the problem [...]]]></description>
			<content:encoded><![CDATA[<p>Maybe it&#8217;s because I have weak PowerPoint computer hacking skills, but whenever I work on a presentation I find myself thinking, &#8220;Shouldn&#8217;t this be easier?&#8221; or &#8220;I&#8217;d rather be doing this with CSS.&#8221;  So last week when I ran into my usual PowerPoint frustration I decided to devote a little time to correct the problem by writing a simple HTML/CSS/Javascript slideshow app.</p>
<p>You might ask, &#8220;Aren&#8217;t there already some browser-based presentation tools out there?&#8221;  Yes!  There&#8217;s <a href="http://www.w3.org/Talks/Tools/Slidy/#(1)" target="_blank">HTML Slidy</a> and Eric Meyer&#8217;s <a href="http://meyerweb.com/eric/tools/s5/" target="_blank">S5</a>.  There&#8217;s also <a href="http://swinger.quirkey.com/#/" target="_blank">Swinger</a>.  And surely others.  Why didn&#8217;t I use one of those?  The truth is that I wasn&#8217;t aware of them.  Writing an HTML slideshow tool is not very difficult (at least in the minimalist fashion that I&#8217;ve conceived it) and I had finished building it before I bothered to see if others existed.</p>
<p>If you want lots of configuration options, both S5 and HTML Slidy look great.  And as a hosted option Swinger looks awesome.  But if you just want a lightweight tool you can use to display HTML slides in your favorite browser, I think this little thing works well.</p>
<h5>What it does</h5>
<p>What I wanted was a way to write slides using HTML and CSS, and to be able to display the slides locally on my Mac in Chrome or Firefox, both of which support full-screen viewing.  Since I didn&#8217;t have to worry about  lesser browsers it was an easy opportunity to break out the HTML5 (although making it play nice in other browsers is first on my to-do list).</p>
<p>The features are better explained in the <a title="HTML Slideshow demo" href="http://www.ravelrumba.com/code/demos/html-slideshow/slideshow.html">demo</a>, but here&#8217;s a quick run-down:</p>
<ul>
<li>Each slide exists as a <code>section</code> element inside an HTML document.</li>
<li>Javascript wrangles up the <code>section</code> elements and turns them into ordered slides.</li>
<li>jQuery is used for a few things, including firing events when new slides are loaded.</li>
<li>You can do some simple intra-slide fade-in stuff by giving things a class of &#8220;action&#8221;.</li>
<li>You can advance through the presentation with either your mouse or the keyboard.</li>
</ul>
<h5>Props</h5>
<p><a href="http://edward.oconnor.cx/" target="_blank">Edward O&#8217;Connor</a> wrote an interesting post about <a href="http://edward.oconnor.cx/2009/08/marking-up-a-slideshow-in-html5" target="_blank">marking up a slideshow in HTML5</a>.  For the structure of the HTML I followed most of his ideas.</p>
<p>That&#8217;s all!  As always, feedback is greatly appreciated.</p>
<p><a title="HTML Slideshow demo" href="http://www.ravelrumba.com/code/demos/html-slideshow/slideshow.html"><strong>View the demo</strong></a><br />
<a title="Download from github" href="http://github.com/robflaherty/html-slideshow"><strong>Download from github</strong></a></p>
<img src="http://feeds.feedburner.com/~r/ravelrumba/~4/2Sx_-0DA9AU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ravelrumba.com/blog/html5-slideshow/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.ravelrumba.com/blog/html5-slideshow/</feedburner:origLink></item>
		<item>
		<title>IE 8 Charset Bug</title>
		<link>http://feeds.ravelrumba.com/~r/ravelrumba/~3/TuuZhll28xE/</link>
		<comments>http://www.ravelrumba.com/blog/ie-8-charset-bug/#comments</comments>
		<pubDate>Fri, 14 May 2010 21:12:38 +0000</pubDate>
		<dc:creator>Rob Flaherty</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[Web Performance]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[charset]]></category>
		<category><![CDATA[ie8]]></category>
		<category><![CDATA[meta tag]]></category>

		<guid isPermaLink="false">http://www.ravelrumba.com/?p=846</guid>
		<description><![CDATA[Earlier today I was playing around with a performance test case when I noticed that stylesheets and scripts were being requested twice in IE8. Eventually I figured out that the problem had to do with how the character set was specified. This is how things seem to work: In IE8, pages that rely on the [...]]]></description>
			<content:encoded><![CDATA[<p>Earlier today I was playing around with a performance test case when I noticed that stylesheets and scripts were being requested twice in IE8. </p>
<p><img src="http://s.ravelrumba.com/uploads/2010/05/ie8-charset-bug-1.png" alt="IE8 Charset bug - Waterfall showing double HTTP requests" title="IE8 Charset bug - Waterfall showing double HTTP requests" width="600" height="126" class="alignnone size-full wp-image-850" /></p>
<p>Eventually I figured out that the problem had to do with how the character set was specified.  This is how things <em>seem</em> to work: In IE8, pages that rely on the <code>META</code> tag to define the character set &#8212; that is, pages that do NOT use the HTTP Content-type header to specify the character set &#8212; will request some stylesheets and scripts twice.  Pages that indicate a character set via the HTTP Content-type header behave properly.</p>
<h5>Test Page Using META Tag</h5>
<p>On this page the character set is specified using only the META tag.  The stylesheet and Javascript requests are sent twice.  Notice that the initial requests do not receive a response.</p>

<div class="wp_syntax"><div class="code"><pre class="html4" style="font-family:monospace;">&lt;meta http-equiv=&quot;Content-type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;</pre></div></div>

<p><img src="http://s.ravelrumba.com/uploads/2010/05/ie8-charset-bug-page1.png" alt="IE8 Charset Bug - Resources requested twice" title="IE8 Charset Bug - Resources requested twice" width="600" height="156" class="alignnone size-full wp-image-862" /></p>
<p><a href="http://lab2.ravelrumba.com/ie8-test/index1.php">View test page</a></p>
<h5>Test Page Using Content-type HTTP Header</h5>
<p>On this page the character set is specified with the Content-type HTTP header.  The stylesheet and Javascript are requested only once.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Content-type: text/html; charset=utf-8'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><img src="http://s.ravelrumba.com/uploads/2010/05/ie8-charset-bug-page3.png" alt="IE8 Charset Bug - Resources requested once" title="IE8 Charset Bug - Resources requested once" width="600" height="123" class="alignnone size-full wp-image-865" /></p>
<p><a href="http://lab2.ravelrumba.com/ie8-test/index3.php">View test page</a></p>
<h5>Other Test Pages</h5>
<p>Interestingly, if you do not specify the character set at all, IE8 does not request the stylesheet and script twice.  <a href="http://lab2.ravelrumba.com/ie8-test/index2.php">View test page</a>.</p>
<p>If you use both the META tag and the Content-type HTTP header, the header will override the META tag and IE8 will only request the resources once.  <a href="http://lab2.ravelrumba.com/ie8-test/index4.php">View test page</a>.</p>
<h5>Is it really a bug?</h5>
<p>I was surprised to see that Googling this quirk did not turn up any results.  My first thought was that the HTTP proxy was reporting false connections.  But I was able to replicate the problem on HttpWatch, Charles, and <a href="http://www.webpagetest.org/" target="_blank">WebPagetest.org</a>.  Additionally, inspecting the server logs revealed the extra requests for the stylesheets (but curiously not the Javascript).</p>
<p>Then I thought it might have something to do with my webhost&#8217;s nginx and Apache configurations.  But I tested some other sites at random and found the same problem with pages that did not specify the charset via HTTP header (two such pages: <a href="http://ejohn.org/">John Resig&#8217;s blog</a> and <a href="http://css3please.com/">css3please.com</a>).</p>
<p>Billy Hoffman has a great post about <a href="http://zoompf.com/blog/2009/12/browser-performance-issues-with-charsets" target="_blank">charset and performance issues</a>, in which he mentions that Firefox will re-request a URL if it detects a new charset after the initial URL request.  That sounds like a very possible explanation for what is going on here: the initial stylesheet and script requests are sent, THEN the browser parses the META tag, forcing the stylesheet and script to be re-requested.  But this seems odd considering the META tag occurs in the document before the stylesheet and script references.</p>
<p>Specifying the character set server-side instead of with the META tag is already considered a best practice, but if this IE8 behavior is accurate, the penalty for not adhering to the best practice is significant.  </p>
<h5>Update (5/16/2010)</h5>
<p> In the comments Dave posted a link to this <a href="http://blogs.msdn.com/ieinternals/archive/2010/04/01/IE8-Lookahead-Downloader-Fixed.aspx">post by Eric Lawrence</a>, which explains the bug and announces that it was (mostly) fixed in a 3/30/10 update.  The post is worth reading, but I wanted to highlight the part where Eric recommends using the Content-type header to specify the character set:</p>
<blockquote><p> However, the Update kills the bug in Scenario #1 by disabling the Lookahead Downloader when a restart is encountered. Hence, we continue to strongly recommend that web developers specify the CHARSET in the HTTP Content-Type response header, as this ensures that the performance benefit of the Lookahead Downloader is realized. </p></blockquote>
<img src="http://feeds.feedburner.com/~r/ravelrumba/~4/TuuZhll28xE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ravelrumba.com/blog/ie-8-charset-bug/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.ravelrumba.com/blog/ie-8-charset-bug/</feedburner:origLink></item>
		<item>
		<title>iPad View Source Bookmarklet</title>
		<link>http://feeds.ravelrumba.com/~r/ravelrumba/~3/9X_JRT489mw/</link>
		<comments>http://www.ravelrumba.com/blog/ipad-view-source-bookmarklet/#comments</comments>
		<pubDate>Mon, 26 Apr 2010 14:01:06 +0000</pubDate>
		<dc:creator>Rob Flaherty</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[General Web]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[ipad]]></category>
		<category><![CDATA[Safari]]></category>
		<category><![CDATA[view source]]></category>

		<guid isPermaLink="false">http://www.ravelrumba.com/?p=761</guid>
		<description><![CDATA[For a few years I&#8217;ve been using this little bookmarklet, written by Abe Fettig, on my iPhone to view page source in Mobile Safari. It works well, but unfortunately the output is not optimized for viewing on the iPhone. Because I use the bookmarklet so infrequently, it&#8217;s never really bothered me. Then I installed the [...]]]></description>
			<content:encoded><![CDATA[<p>For a few years I&#8217;ve been using this <a href="http://fettig.net/weblog/2007/07/02/view-source-for-safari-on-iphone/" target="_blank">little bookmarklet</a>, written by Abe Fettig, on my iPhone to view page source in Mobile Safari.  It works well, but unfortunately the output is not optimized for viewing on the iPhone.  Because I use the bookmarklet so infrequently, it&#8217;s never really bothered me.</p>
<p>Then I installed the same bookmarklet on my iPad.  I found myself using the iPad to browse the web more often, and more often wanting to click <em>view source</em>.  Quickly the poor screen formatting became enough of a nuisance to motivate me to spend a few lines of code fixing it.</p>
<p>Here&#8217;s an example of the source produced by Abe Fettig&#8217;s original bookmarklet (on the iPad):</p>
<h5>Original View Source</h5>
<p><a href="http://s.ravelrumba.com/uploads/2010/04/ipad-view-source-1.png"><img src="http://s.ravelrumba.com/uploads/2010/04/ipad-view-source-1.png" alt="Original iPad View Source Example" title="Original iPad View Source Example" width="600" height="300" class="alignnone size-full wp-image-788" /></a></p>
<p>It takes a lot of zoom pinching to get the text to a legible level.  Here&#8217;s an example of what the improved version displays:</p>
<h5>New and Improved</h5>
<p><img src="http://s.ravelrumba.com/uploads/2010/04/ipad-view-source-2.png" alt="Revised iPad View Source Example" title="Revised iPad View Source Example" width="600" height="300" class="alignnone size-full wp-image-790" /></p>
<p>Much better.  To do it I made two small additions (and a few tweaks) to the original.  One, I added a viewport meta tag, setting the width to <code>device-width</code>.  And two, I added <code>overflow:auto</code> and <code>white-space: pre-wrap</code> styles to the <code>pre</code> element wrapping the displayed source code.  Behold:  </p>
<h5>Improved Bookmarklet Code</h5>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">javascript<span style="color: #339933;">:</span><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: #003366; font-weight: bold;">var</span> w <span style="color: #339933;">=</span> window.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'about:blank'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> 
        s <span style="color: #339933;">=</span> w.<span style="color: #660066;">document</span><span style="color: #339933;">;</span>
    s.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt;&lt;title&gt;Source of '</span> <span style="color: #339933;">+</span> location.<span style="color: #660066;">href</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;/title&gt;&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width&quot; /&gt;&lt;/head&gt;&lt;body&gt;&lt;/body&gt;&lt;/html&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    s.<span style="color: #000066;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> pre <span style="color: #339933;">=</span> s.<span style="color: #660066;">body</span>.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>s.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;pre&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    pre.<span style="color: #660066;">style</span>.<span style="color: #660066;">overflow</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'auto'</span><span style="color: #339933;">;</span>
    pre.<span style="color: #660066;">style</span>.<span style="color: #660066;">whiteSpace</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'pre-wrap'</span><span style="color: #339933;">;</span>
    pre.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>s.<span style="color: #660066;">createTextNode</span><span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">documentElement</span>.<span style="color: #660066;">innerHTML</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</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>If you already know how to install a bookmarklet in Mobile Safari, here&#8217;s the <a href="/wp/wp-content/code/view-source.txt">raw code</a>.  Have fun.</p>
<p>For the rest of you, who might be thinking, &#8220;how do I get this teh hotness onto my business?&#8221;, worry not.  We&#8217;ve got you covered.  It&#8217;s like this&#8230;</p>
<h5>How to Install a Bookmarklet on Mobile Safari</h5>
<p>Navigate to this page on your iPad and select &#8220;Add Bookmark&#8221;.  Change the name of the bookmark to &#8220;View Source&#8221; or whatever you like.  Tap &#8220;Save&#8221;. </p>
<p>Next, copy <a href="/wp/wp-content/code/view-source.txt">the bookmarklet from here</a>.  (Select All > Copy.)</p>
<p>Lastly, go to your bookmarks, tap &#8220;Edit&#8221;, select the bookmark you just created, and replace the URL by pasting in the new code.  Tap &#8220;Done&#8221; and you&#8217;re done.</p>
<p>A few things:</p>
<ul>
<li>The source you&#8217;ll see is the DOM source (&#8220;generated source&#8221;), not the original HTML source.</li>
<li>The ends of some very long strings are partly hidden from view.</li>
<li>It works well on the iPad but on the iPhone the text wrapping does not work as well (the ends of more lines are cut off).</li>
<li>It should work in any browser that supports the <code>white-space</code> value <code>pre-wrap</code>.  But I&#8217;ve only tested on iPad, iPhone, and Opera Mini on the iPhone.</li>
<li>For some reason the source code output is not fully selectable.  You can Select All but you cannot define segments to select.</li>
</ul>
<p>If anyone knows of a better solution, or has any recommendations to improve this one, please let me know.  You can also fork the <a href="http://gist.github.com/379356" target="_blank">gist</a> on github.</p>
<img src="http://feeds.feedburner.com/~r/ravelrumba/~4/9X_JRT489mw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ravelrumba.com/blog/ipad-view-source-bookmarklet/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://www.ravelrumba.com/blog/ipad-view-source-bookmarklet/</feedburner:origLink></item>
		<item>
		<title>iPad HTTP Debugging with Charles</title>
		<link>http://feeds.ravelrumba.com/~r/ravelrumba/~3/M4A0G19k-Uk/</link>
		<comments>http://www.ravelrumba.com/blog/ipad-http-debugging/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 21:09:47 +0000</pubDate>
		<dc:creator>Rob Flaherty</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Web Performance]]></category>
		<category><![CDATA[charles]]></category>
		<category><![CDATA[debugger]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[ipad]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[proxy]]></category>

		<guid isPermaLink="false">http://www.ravelrumba.com/?p=733</guid>
		<description><![CDATA[After noticing that the caching in iPad Safari seemed a little funky, I made an effort to decipher some of the logic used by the browser cache. I didn&#8217;t get very far, but in the process I figured out how to route my iPad HTTP traffic through a web debugger on my laptop. It turns [...]]]></description>
			<content:encoded><![CDATA[<p>After noticing that the caching in iPad Safari seemed a little funky, I made an effort to decipher some of the logic used by the browser cache.  I didn&#8217;t get very far, but in the process I figured out how to route my iPad HTTP traffic through a web debugger on my laptop.  It turns out it was very easy to do (although I&#8217;m sure there is a more complicated way to go about it).  </p>
<p>What follows is a simple step-by-step for connecting your iPad to an HTTP debugging proxy.  The main requirement is that your desktop/laptop and iPad be on the same wireless network.  Then it&#8217;s just a matter of telling your iPad to use your desktop as an HTTP proxy.</p>
<p>I&#8217;m going to walk through how to do this on a Mac with the highly recommended HTTP proxy app <a href="http://www.charlesproxy.com/" target="_blank">Charles</a>, but the same basic steps should also work for a Windows HTTP debugger such as <a href="http://www.fiddler2.com/fiddler2/" target="_blank">Fiddler</a>. (Update: Fiddler users, see Eric Lawrence&#8217;s <a href="#li-comment-560">comment</a> below.)  Additionally, the steps are the same for connecting your iPhone or iPod Touch.</p>
<h5>1. Get your system IP address for your desktop</h5>
<p>The easiest way to do this on a Mac is to Spotlight your way to the &#8220;Network Utility&#8221; app.  Make sure you&#8217;re on your Wi-Fi network and take note of the IP address.  This is your desktop&#8217;s local IP.  </p>
<p><img class="alignnone size-full wp-image-735" title="ipad-http-proxy-network" src="http://s.ravelrumba.com/uploads/2010/04/ipad-http-proxy-network.png" alt="iPad HTTP Proxy Network Utility" width="600" height="376" /></p>
<h5>2. Tell your iPad about your desktop IP</h5>
<p>On your iPad, go to Settings > Wi-Fi and click the arrow next your Wi-Fi connection.  Under &#8220;HTTP Proxy&#8221;, select the Manual button and enter your desktop&#8217;s IP address in the Server field.  Then enter &#8220;8888&#8243; in the Port field.  Close out.</p>
<p><img class="alignnone size-full wp-image-736" title="ipad-http-proxy-settings" src="http://s.ravelrumba.com/uploads/2010/04/ipad-http-proxy-settings.png" alt="iPad HTTP proxy settings" width="600" height="249" /></p>
<h5>3. Configure Charles</h5>
<p>Open Charles and select Proxy > Proxy Settings. Under the Proxies tab, make sure the HTTP proxy value is set to 8888.  Then click the &#8220;Mac OS X&#8221; tab and check &#8220;Enable Mac OS X Proxy&#8221; and &#8220;Use HTTP Proxy&#8221;.  Click OK.  </p>
<p><img class="alignnone size-full wp-image-738" title="charles-proxy-settings" src="http://s.ravelrumba.com/uploads/2010/04/charles-proxy-settings.png" alt="Charles proxy settings" width="600" height="445" /></p>
<h5>4. Start capturing HTTP traffic</h5>
<p>Click the Record button in Charles and then load a web page in iPad Safari.  You should see the following alert asking you if you want to allow your iPad to connect to Charles. Select &#8220;Allow&#8221;.</p>
<p><img class="alignnone size-full wp-image-739" title="charles-proxy-alert" src="http://s.ravelrumba.com/uploads/2010/04/charles-proxy-alert.png" alt="charles proxy alert" width="600" height="261" /></p>
<p>Now all of your HTTP traffic in iPad Safari should be recorded by Charles.  </p>
<p>When you&#8217;re finished doing all of your fun HTTP debugging, don&#8217;t forget to <strong>turn off</strong> the HTTP proxy in the Wi-Fi settings of your iPad.</p>
<img src="http://feeds.feedburner.com/~r/ravelrumba/~4/M4A0G19k-Uk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ravelrumba.com/blog/ipad-http-debugging/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		<feedburner:origLink>http://www.ravelrumba.com/blog/ipad-http-debugging/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 0.638 seconds. --><!-- Cached page generated by WP-Super-Cache on 2010-08-18 15:19:36 -->
