<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10titles.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemtitles.css"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">

	<title>Joni Korpi</title>
	
	<link href="http://jonikorpi.com/" hreflang="en" rel="alternate" type="text/html" />
	
	<updated>2012-05-05T23:27:32+10:00</updated>
	<generator uri="http://staceyapp.com/" version="2.3.0">Stacey</generator>
	
	<id>tag:jonikorpi,2011:feed/</id>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/jonikorpi" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="jonikorpi" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Fjonikorpi" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><entry>
   <title>Leaving Old Internet Explorer Behind</title>
   <id>tag:jonikorpi,2011:leaving-old-IE-behind/</id>
   <updated>2011-12-30T11:51:16+11:00</updated>
   <link rel="alternate" type="text/html" href="http://jonikorpi.com/leaving-old-IE-behind/" />
   <rights>Licensed under Creative Commons Attribution (http://creativecommons.org/licenses/by/3.0/). Please attribute Joni Korpi and link back to http://jonikorpi.com</rights>
   	<author>
		<name>Joni Korpi</name>
		<uri>http://jonikorpi.com</uri>
	</author>
	<summary>Using media queries to make a clean break from legacy browsers.</summary>
	<content type="html">
			<p>Using media queries to make a clean break from legacy browsers.</p>
			
				<p>This site was designed <a href="http://www.lukew.com/ff/entry.asp?933">Mobile First</a>. The styles that make up the mobile version of its layout, which I’ll call the Narrow Layout from now on, are not inside a media query, while the styles that make up the wider versions are. As a result, browsers with no support for media queries will only see the Narrow Layout. This is a good thing.</p>

<p>Instead of enabling media queries in the browsers that don’t support them, like Internet Explorer 6–8, I chose to simply serve them the Narrow Layout, slightly enhanced with Paul Irish’s <a href="http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/">IE conditional classes</a>.</p>

<p>For example, I gave the layout a static width to make sure the content never stretches uncomfortably wide, and made sure images always display at full size, since I had halved their maximum sizes in the Narrow Layout.</p>

<pre><code>body {
    width: auto;
}
    .ie body {width: 540px;}

#content figure {
    width: 240px;
    max-width: 100%;
}
    .ie #content figure {width: 480px;}
</code></pre>

<p>As a result, old mobile browsers will see a fluid single-column layout, and IE6–8 will see a similar static-width layout, perfectly comfortable for reading even on larger screens.</p>

<figure class="full">
    <img src="../imgs/leaving-old-IE-behind.jpg" alt="This site in IE7" />
    <figcaption>This is roughly what this site looks like in IE7.</figcaption>
</figure>

<p>So that’s old IE and old mobile browsers taken care of. Now comes the fun part. Since I can be sure that legacy browsers won’t be seeing any of the wider versions of my layout, I’m free to design them with the assumption that they’ll <em>most likely</em> be viewed in a browser that supports such <a href="http://caniuse.com/#eras=now,near,far&amp;cats=CSS">luxuries</a> as…</p>

<ul>
<li>2D transforms</li>
<li>CSS2.1 selectors: <code>+ &gt; [attr]</code></li>
<li>most <a href="http://www.quirksmode.org/css/contents.html#CSS3">CSS3 selectors</a></li>
<li><code>Partial 'before' not found</code> and <code>Partial 'after' not found</code></li>
<li><code>opacity</code>, <code>box-shadow</code>, and <code>text-shadow</code> </li>
<li><code>min/max-width</code> and <code>min/max-height</code></li>
<li><code>box-sizing</code> and <code>inline-block</code></li>
<li><code>rgba()</code> and <code>hsla()</code></li>
<li>and even root-ems!</li>
</ul>

<p>Suddenly all the shackles imposed by old IE are gone. <em>I can even use margins on floated elements.</em> I’ll just let that sink in for a moment.</p>

<p>I think I’ll be using this technique to deal with legacy browsers from now on. It requires no Javascript, no hacks, no separate stylesheets, and barely any effort, since single-column layouts rarely require the kind of advanced positioning that IE6 will have problems with. In this site’s case, I had to write less than a dozen lines of CSS to make the Narrow Layout comfortable to view in old IE. Simple, effortless, and oh so liberating.</p>

			
	</content>
</entry>
	<entry>
   <title>A Smoother Page Load</title>
   <id>tag:jonikorpi,2011:a-smoother-page-load/</id>
   <updated>2011-08-10T22:49:27+10:00</updated>
   <link rel="alternate" type="text/html" href="http://jonikorpi.com/a-smoother-page-load/" />
   <rights>Licensed under Creative Commons Attribution (http://creativecommons.org/licenses/by/3.0/). Please attribute Joni Korpi and link back to http://jonikorpi.com</rights>
   	<author>
		<name>Joni Korpi</name>
		<uri>http://jonikorpi.com</uri>
	</author>
	<summary>An unexpected opportunity to control how the page loads, using Typekit.</summary>
	<content type="html">
			<p>An unexpected opportunity to control how the page loads, using Typekit.</p>
			
				<p>I finally have a blog. For the longest time I haven’t been able to let out the endless rambles about all the little design detail and theories bouncing around in my head. Now I can, and <em>will.</em></p>

<p>I’m going to start by going over a little trick I discovered when designing this site. When you opened this page, you may noticed that it took a moment longer to load than usual, and that it didn’t just blink into existence, but <em>faded in.</em></p>

<p>The culprit behind the extra loading time is the <a href="http://blog.typekit.com/2011/05/25/loading-typekit-fonts-asynchronously/">asynchronous Typekit snippet</a>, which loads the web fonts used on this site. Unlike the regular Typekit snippet, the asynchronous one doesn’t automatically protect you against the Flash of Unstyled Content that can happen if the fonts don’t load quickly enough, so I had to take care of that manually.</p>

<p>I had to make sure no text elements on the page would show until the fonts have finished loading. To accomplish this, I simply set the opacity of all text on the page to zero using the <code>.wf-loading</code> class provided by the Typekit snippet. I also added a fallback for versions of IE that don’t support opacity.</p>

<pre><code>.wf-loading h1, 
.wf-loading h2, 
.wf-loading h3, 
.wf-loading p, 
.wf-loading li {
    opacity: 0;
}

.ie.wf-loading h1, 
.ie.wf-loading h2, 
.ie.wf-loading h3, 
.ie.wf-loading p, 
.ie.wf-loading li {
    visibility: hidden; /* Old IE */
}
</code></pre>

<p>While playing around with this, I realised I could also control how the text eventually appears after the fonts have finished loading. By adding a very short CSS transition, I could make it fade in.</p>

<pre><code>h1, h2, h3, p, li {
    opacity: 1;
    visibility: visible; /* Old IE */
    -webkit-transition: opacity 0.24s ease-in-out;
       -moz-transition: opacity 0.24s ease-in-out;
            transition: opacity 0.24s ease-in-out;
}
</code></pre>

<p>This should work in most modern desktop and mobile browsers, including IE9. The fade-in might feel a bit laggy on underpowered computers and mobile devices that don’t use GPU rendering, but that’s okay, since it’ll feel more or less just like a regular blinking-into-existence page load.</p>

<p>There was one downside though: hiding the content made the initial load seem slower. Even though the site is progressively rendering into existence in the background, we can’t see it, which makes the load time <em>feel</em> longer.</p>

<p>To alleviate this effect, I added a little loading spinner as a GIF image. Since the spinner needed to appear immediately, I embedded it into my stylesheet using a <a href="http://css-tricks.com/5970-data-uris/">data URI</a>. I used Opinionated Geek’s <a href="http://www.opinionatedgeek.com/dotnet/tools/base64encode/">Base 64 encoder</a> to encode image and embedded it as follows:</p>

<pre><code>.wf-loading #content header {
    background: 
        url(data:image/gif;base64,lots-of-base64…) 
        center center no-repeat
    ;
}
</code></pre>

<figure class="full">
    <img src="../imgs/a-smoother-page-load.png" alt="Loading spinner vs. no loading spinner" />
    <figcaption>Before and after. The spinner makes it clear something is happening.</figcaption>
</figure>

<p>This should work just fine in all modern browsers, including IE8–9. IE6–7 will simply ignore it, which is fine by me. This is just a minor detail after all.</p>

<p>The resulting effect is pretty interesting, isn’t it? It doesn’t feel like a regular HTML page load, but not exactly like an AJAX load either.</p>

<p>This technique could also be applied to images or even the entire page. Theoretically you could even create all sorts of Powerpoint-esque transitions using CSS transforms. It’s good to practice restraint though, as these effects can be quite performance-intensive. Also, the simpler and faster the transition is, the less likely it is to annoy anyone — good transitions are felt, not noticed. Personally, I think this one turned out pretty good, but I’d love to hear your opinions about it <a href="http://twitter.com/jonikorpi">on Twitter</a>.</p>

<p><strong>Update on 23 Jul 2011:</strong> The IE fallback was causing the fade-in to feel jerky in Safari, so I split it off into a separate declaration using an <a href="http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/">IE conditional class</a>. It will probably not work in IE6, but will in IE7–8.</p>

<p><strong>Update on 2 Aug 2011:</strong> The fade-in on this site is currently disabled while I’m investigating whether it has something to do with the mysterious plummeting of this site’s Google ranking.</p>

<p><strong>Update on 10 Aug 2011:</strong> The fade-in is back in action. It doesn’t seem to have caused my ranking problems.</p>

			
	</content>
</entry>


</feed><!-- Stacey(2.3.0). -->
