<?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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Learning the World &#187; css sprites</title>
	<atom:link href="http://learningtheworld.eu/tag/css-sprites/feed/" rel="self" type="application/rss+xml" />
	<link>http://learningtheworld.eu</link>
	<description></description>
	<lastBuildDate>Tue, 06 Nov 2012 00:17:33 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.9.1</generator>
	<item>
		<title>Better Foreground Sprites</title>
		<link>http://learningtheworld.eu/2008/better-foreground-sprites/</link>
		<comments>http://learningtheworld.eu/2008/better-foreground-sprites/#comments</comments>
		<pubDate>Thu, 26 Jun 2008 18:00:17 +0000</pubDate>
		<dc:creator><![CDATA[Martin Kliehm]]></dc:creator>
				<category><![CDATA[accessibility]]></category>
		<category><![CDATA[conferences]]></category>
		<category><![CDATA[downloads]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[background-image]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[css sprites]]></category>
		<category><![CDATA[foreground sprites]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[http-request]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[T.V. Raman]]></category>

		<guid isPermaLink="false">http://learningtheworld.eu/?p=106</guid>
		<description><![CDATA[A while ago I wrote about using <acronym title="Cascading Style Sheets">CSS</acronym> Sprites in <code>img</code> tags&#160;&#8212; <strong>Foreground Sprites</strong>. Thus you avoid HTTP requests, but the page turns really ugly when <acronym>CSS</acronym> is switched off because the sprite image will be displayed in its full size. Now Google&#8217;s accessibility specialist T.V. Raman explained their idea of using sprites for foreground images&#160;&#8212; a much better solution!]]></description>
				<content:encoded><![CDATA[<p>A while ago I wrote about using <a href="http://www.alistapart.com/articles/sprites/"><acronym title="Cascading Style Sheets">CSS</acronym> Sprites</a> in <code>img</code> tags, calling it <strong><a href="/2007/foreground-sprites/">Foreground Sprites</a></strong>. Thus you avoid performance-eating HTTP requests, but the page turns really ugly when <acronym>CSS</acronym> is switched off because the sprite image will be displayed in its full size. <img src="http://learningtheworld.eu/wp-includes/images/smilies/icon_sad.gif" alt=":(" class="wp-smiley" /> </p>

<p>What are the alternatives? Using background-images with off-screen text? Bad code:</p>

<ol class="code bad" title="HTML">
<li><code>&lt;a href=&quot;foo&quot; class=&quot;button&quot;&gt;</code></li>
<li class="indent"><code>&lt;span&gt;Alternative Text&lt;/span&gt;</code></li>
<li><code>&lt;/a&gt;</code></li>
</ol>

<ol class="code bad" title="CSS">
<li><code>a.button, button {</code></li>
<li class="indent"><code>background: url(foo.gif) 0 &minus;26px no-repeat;</code></li>
<li class="indent">display: block;</li>
<li class="indent">height: 52px;</li>
<li class="indent">overflow: hidden;</li>
<li class="indent">position: relative;</li>
<li class="indent">width: 150px;</li>
<li><code>}</code></li>
<li><code>span {</code></li>
<li class="indent"><code>left: &minus;9999px;</code></li>
<li class="indent"><code>position: absolute;</code></li>
<li class="indent"><code>top: auto;</code></li>
<li><code>}</code></li>
</ol>

<p><strong>That&rsquo;s a bad idea with accessibility issues.</strong> Screen readers will be able to read the text, but if somebody with low vision has high-contrast custom stylesheets, it is likely that the <code>background-image</code> won&rsquo;t be displayed. Still the alternative text will be invisible off-screen, so the link or <code>button</code> becomes unusable.</p>

<h3>A better solution</h3>

<p>Now Google&rsquo;s accessibility specialist <strong>T.V. Raman</strong> explained their idea for <a href="http://googlewebmastercentral.blogspot.com/2008/05/design-patterns-for-accessible.html">replacing  images with sprites</a>. Here are screenshots of Google search results with images, and with background images disabled:</p>

<p><img src="/wp-content/uploads/2008/06/screenshot-google-search-result-with-bgimage.png" width="400" height="84" alt="Screenshot displaying the Google logo" class="screenshot" />
<img src="/wp-content/uploads/2008/06/screenshot-google-search-result-wo-bgimage.png" width="400" height="84" alt="Screenshot with text visible instead of the logo" class="screenshot" /></p>

<p>Google puts the alternative text <strong><em>behind</em> the background image</strong> simply by attaching it on the <code>span</code> element, not the anchor. So when <acronym>CSS</acronym> or background images are turned off, the text just reappears.</p>

<ol class="code" title="XHTML">
<li><code>&lt;a id=&quot;logo&quot; title=&quot;Go to Google Home&quot; href=&quot;http://www.google.com/&quot;&gt;</code></li>
<li class="indent">Google</li>
<li class="indent"><code><strong>&lt;span&gt;<ins datetime="20080627T174700">&lt;/span&gt;</ins></strong></code></li>
<li><code>&lt;/a&gt;</code></li>
</ol>

<ol class="code" title="CSS">
<li><code>#logo {</code></li>
<li class="indent">display: block;</li>
<li class="indent">height: 52px;</li>
<li class="indent">overflow: hidden;</li>
<li class="indent">position: relative;</li>
<li class="indent">width: 150px;</li>
<li><code>}</code></li>
<li><code>#logo span {</code></li>
<li class="indent"><code>background: url(foo.gif) 0 &minus;26px no-repeat;</code></li>
<li class="indent"><code>height: 100%;</code></li>
<li class="indent"><code>left: 0;</code></li>
<li class="indent">position: absolute;</li>
<li class="indent">top: 0;</li>
<li class="indent"><code>width: 100%;</code></li>
<li><code>}</code></li>
</ol>

<p>There&rsquo;s only an issue if you have <em>a lot</em> of alternative text, perhaps combined with text zoom, so that it doesn&rsquo;t fit in the reserved space. But I can live with that.</p>

<p>Congratulations to Google for this ellegant solution, and it&rsquo;s <em>so</em> simple! Why didn&rsquo;t <em>I</em> think of it? <img src="http://learningtheworld.eu/wp-includes/images/smilies/icon_wink.gif" alt=";)" class="wp-smiley" /> </p>
]]></content:encoded>
			<wfw:commentRss>http://learningtheworld.eu/2008/better-foreground-sprites/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Foreground Sprites</title>
		<link>http://learningtheworld.eu/2007/foreground-sprites/</link>
		<comments>http://learningtheworld.eu/2007/foreground-sprites/#comments</comments>
		<pubDate>Thu, 26 Jul 2007 13:00:55 +0000</pubDate>
		<dc:creator><![CDATA[Martin Kliehm]]></dc:creator>
				<category><![CDATA[accessibility]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[css sprites]]></category>
		<category><![CDATA[DOM scripting]]></category>
		<category><![CDATA[foreground sprites]]></category>
		<category><![CDATA[hover]]></category>
		<category><![CDATA[image swapping]]></category>
		<category><![CDATA[img element]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[mouseover]]></category>
		<category><![CDATA[rollover]]></category>

		<guid isPermaLink="false">http://learningtheworld.eu/2007/foreground-sprites/</guid>
		<description><![CDATA[Most rollovers have become obsolete because they can be performed on background images with <strong><acronym title="Cascading Style Sheets">CSS</acronym> sprites</strong>. However, there are those rare cases when there is just an icon without text, like a &#8220;play&#8221; or &#8220;pause&#8221; button. This article discusses how to apply <acronym>CSS</acronym> sprites for foreground images.&#160;[&#8230;]]]></description>
				<content:encoded><![CDATA[<p class="alert"><ins datetime="20080626T200000">Please consider a better solution with <a href="/2008/better-foreground-sprites/">Better Foreground Sprites</a>.</ins></p>

<p>Most rollovers have become obsolete because they can be performed on background images with <strong><a href="http://www.alistapart.com/articles/sprites/"><acronym title="Cascading Style Sheets">CSS</acronym> sprites</a></strong>. If there are hover effects today, they usually come as text on a button background image, or as a text link with an icon next to it.</p>

<p>However, there are those rare cases when there is <strong>just an icon without text</strong>, like a &ldquo;play&rdquo; or &ldquo;pause&rdquo; button, or a magnification glass on an image to signal it can be enlarged. If you want to swap images when the element receives focus or on mouseover, traditionally you are stuck with two options:</p>

<ol>
<li>JavaScript to change the image source, or</li>
<li><acronym>CSS</acronym> sprites to change the position of a background image behind a transparent <code>gif</code> image.</li>
</ol>

<p>I like neither. Using JavaScript and two images with pre-loading seems like a waste of resources when it can be done with <acronym>CSS</acronym> and one image only. Transparent gifs are <em>so</em> 1998, besides the background usually doesn&rsquo;t get printed. So what we need on these occasions are <strong><acronym>CSS</acronym> sprites for foreground images</strong>.</p>

<p>Until recently I thought that can&rsquo;t be done, but then I stumbled upon some code for <a href="http://download.dojotoolkit.org/release-0.9.0beta/dojo-0.9.0beta/dijit/tests/form/test_Checkbox.html">checkbox widgets in Dojo</a>. Naturally they use a lot of JavaScript for the task. Anyway I like my default checkboxes and don&rsquo;t have any urge to make them prettier (I have no doubt our design overlords would enforce <em>aqua</em> icons everywhere), but that made me think. Here&rsquo;s a suggestion:</p>

<p>First a simple sprite which is 50px wide: <img src="/examples/img/icon-enlarge.gif" width="50" height="15" alt="Two icons of a magnification glass" class="example sprite" /></p>

<p>The <acronym title="Hypertext Markup Language">HTML</acronym> code uses the dimensions of a <em>single</em> icon for width and height to allow fast page rendering without reflow:</p>

<ol class="code">
<li><code>&lt;a href=&quot;/big/&quot; class="icon"&gt;</code></li>
<li class="indent"><code>&lt;img src=&quot;/img/icon-enlarge.gif&quot; id=&quot;magnifier&quot; <strong>width=&quot;19&quot; height=&quot;15&quot;</strong> alt=&quot;enlarge image&quot; /&gt;</code></li>
<li><code>&lt;/a&gt;</code></li>
</ol>

<p>The corresponding <acronym>CSS</acronym> sets the link to <code>display: block</code>, uses the single icon dimensions for the container, prevents overflow, and resets the image dimensions to <code>auto</code> to prevent distortion. The actual image swapping is achieved by a negative left margin on hover.</p>

<ol class="code">
<li><code>a.icon {</code></li>
<li class="indent"><code><strong>display: block;</strong></code></li>
<li class="indent"><code><strong>width: 19px;</strong></code></li>
<li class="indent"><code><strong>height: 15px;</strong></code></li>
<li class="indent"><code><strong>overflow: hidden;</strong></code></li>
<li><code>}</code></li>
<li><code>a.icon img {</code></li>
<li class="indent"><code><strong>width: auto;</strong></code></li>
<li class="indent"><code><strong>height: auto;</strong></code></li>
<li class="indent"><code>border: none;</code></li>
<li><code>}</code></li>
<li><code>a.icon:hover img, a.icon:focus img, a.icon img.hover {</code></li>
<li class="indent"><code><strong>margin-left: &minus;31px;</strong></code></li>
<li><code>}</code></li>
</ol>

<p>For the sake of simplicity I ignored how the link would be floated or positioned. Also borders, a background color, or padding to increase the clickable area can be added to the parent element.</p>

<p>For simplicity I chose a link in the example, but the same can be done with a <code>div</code> surrounding an <code>&lt;input type=&quot;image&quot;&nbsp;/&gt;</code>. Then of course you need to define <code>cursor: pointer</code>, and for anything below <acronym title="Internet Explorer">IE</acronym>7 bind the <acronym title="Document Object Model">DOM</acronym> event to the hovering element (<a href="/examples/js/foreground-sprites-ie6.js" type="text/javascript" title="JavaScript source code to fix Internet Explorer">get the source</a>):</p>

<ol class="code">
<li><code>&lt;!--[if lt IE 7]&gt;</code></li>
<li><code>&lt;script type=&quot;text/javascript&quot;&gt;</code></li>
<li><code>oIcon = {</code></li>
<li class="indent"><code>setHoverClass : function() {</code></li>
<li class="indent"><code><span class="indent"><strong>this.className = &#x27;hover&#x27;;</strong></span></code></li>
<li class="indent"><code>},</code></li>
<li class="indent"><code>resetHoverClass : function() {</code></li>
<li class="indent"><code><span class="indent"><strong>this.className = &#x27;&#x27;;</strong></span></code></li>
<li class="indent"><code>}</code></li>
<li><code>};</code></li>
<li><code>var elm = document.getElementById(&#x27;magnifier&#x27;);</code></li>
<li><code>if (elm) {</code></li>
<li class="indent"><code>elm.onmouseover = elm.onfocus = oIcon.setHoverClass;</code></li>
<li class="indent"><code>elm.onmouseout = elm.onblur = oIcon.resetHoverClass;</code></li>
<li><code>}</code></li>
<li><code>&lt;/script&gt;</code></li>
<li><code>&lt;![endif]--&gt;</code></li>
</ol>

<p><strong>Here is a working example</strong>. You know how to adjust the code if you need more than one class on the image.</p>

<p><a href="#" class="icon"><img src="/examples/img/icon-enlarge.gif" id="magnifier" width="19" height="15" alt="enlarge image" /></a></p>

<p>That was nice and easy. It&rsquo;s tested in Firefox&nbsp;2, Opera&nbsp;9, Internet Explorer 5+, and Safari&nbsp;2. Screen readers should be okay with the <code>alt</code> text.</p>

<h3>Discussion</h3>

<p>The trouble begins when people <strong>start turning off browser features</strong>.</p>

<p>People with <strong>disabled images</strong> won&rsquo;t be able to read the alternative text because the visible area is limited by the parent container. That can be detected by comparing the known sprite size with the <code>alt</code> text size. Then the class is set to anything but <code>icon</code> so that the parent container expands.</p>

<p>More severe is when people <strong>disable style sheets</strong> because then they will see a squeezed image with multiple icons. If you are hyper-correct, you could replace the crushed multi-icon image with the correct single icon (you could use the <code>class</code> or <code>rel</code> attribute to define the icon type), but nobody wants to slice images. As a compromise I would suggest to replace the icon with its <code>alt</code> text.</p>

<p>See the <a href="/examples/js/foreground-sprites-access.js" type="text/javascript" title="JavaScript source code for accessibility">script</a> to detect disabled images or <acronym>CSS</acronym>. (Note: it isn&rsquo;t implemented here because I couldn&rsquo;t test it properly on <acronym>IE</acronym>6 with stuff turned off.)</p>

<p>If JavaScript is unavailable, the user is stranded with what we gave him. Also <strong>icons without text are inherently evil</strong> because they can&rsquo;t be enlarged by zoom readers. Did I forget any politically correct disclaimer for obscure use scenarios?</p>

<p>So we ended up with a <acronym>CSS</acronym> only version, but still some JavaScript is needed for the extra effort to provide the same experience to users of <acronym>IE</acronym> 5-6, and some more for certain user scenarios. Wouldn&rsquo;t it be easier to slice and swap foreground images the old way? But then again slicing is a pain, and people already start using background images. <strong>Do people actually turn off <acronym>CSS</acronym> and images?</strong> Or is that another remnant of <acronym title="Web Content Accessibility Guidelines">WCAG</acronym> 1.0 from 1999?</p>
]]></content:encoded>
			<wfw:commentRss>http://learningtheworld.eu/2007/foreground-sprites/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Website Performance Tweaks</title>
		<link>http://learningtheworld.eu/2007/performance/</link>
		<comments>http://learningtheworld.eu/2007/performance/#comments</comments>
		<pubDate>Thu, 25 Jan 2007 20:00:35 +0000</pubDate>
		<dc:creator><![CDATA[Martin Kliehm]]></dc:creator>
				<category><![CDATA[downloads]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[book:isbn=0596529309]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[concat]]></category>
		<category><![CDATA[css sprites]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[Douglas Crockford]]></category>
		<category><![CDATA[Ed Eliot]]></category>
		<category><![CDATA[file aggregation]]></category>
		<category><![CDATA[http-request]]></category>
		<category><![CDATA[JSMin]]></category>
		<category><![CDATA[mozilla]]></category>
		<category><![CDATA[Nate Koechley]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[sliding doors]]></category>
		<category><![CDATA[techniques]]></category>
		<category><![CDATA[yahoo]]></category>
		<category><![CDATA[yui]]></category>

		<guid isPermaLink="false">http://learningtheworld.eu/2007/performance/</guid>
		<description><![CDATA[In the last six months I became more aware of techniques for optimizing website performance. I learned about memory leaks and JavaScript performance, but what impressed me most was Nate Koechleyâ€™s presentation about large scale website performance issues in â€œYahoo! <abbr title="versus">vs.</abbr> Yahoo!&#8221; at the @media conference 2006. In the meantime there have been more blog posts about particular aspects of performance optimization, so I wrote a summary.&#160;[&#8230;]]]></description>
				<content:encoded><![CDATA[<p>In the last six months I became more aware of techniques for <strong>optimizing website performance</strong>. I learned about <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/IETechCol/dnwebgen/ie_leak_patterns.asp" title="Microsoft Developer Network: Understanding and solving Internet Explorer leak patterns">memory</a> <a href="http://outofhanwell.com/ieleak/" title="Drip: A memory leak detector for Internet Explorer">leaks</a> and <a href="http://blogs.msdn.com/ie/archive/2006/08/28/728654.aspx" title="IE + JavaScript performance recommendations &ndash; part 1">JavaScript</a> <a href="http://blogs.msdn.com/ie/archive/2006/11/16/ie-javascript-performance-recommendations-part-2-javascript-code-inefficiencies.aspx" title="IE + JavaScript performance recommendations &ndash; part 2">performance</a>, but what impressed me most was <a href="http://nate.koechley.com/blog/2006/07/12/my_atmedia_2006_slides/" rel="met colleague">Nate Koechley&rsquo;s presentation</a> about large scale website performance issues in &ldquo;<a href="http://learningtheworld.eu/2006/atmedia-day-two/#koechley" title="See my notes about his talk">Yahoo! <abbr title="versus">vs.</abbr> Yahoo!</a>&rdquo; at the @media conference 2006. In the meantime there have been more blog posts about particular aspects of performance optimization, and I&rsquo;d like to sum them up:</p>

<p id="file-location"><strong>Parsing JavaScript</strong> freezes the browser. Therefore put <acronym title="Cascading Stylesheets">CSS</acronym> in the <code>head</code> and JavaScript near to the <code>&lt;/body&gt;</code> so that it is parsed when the page has been rendered.</p>

<p id="http-requests">The arch enemy of performance are <strong><a href="http://yuiblog.com/blog/2006/11/28/performance-research-part-1/" title="YUI Blog: Performance research &ndash; what the 80/20 rule tells us about reducing HTTP requests"><acronym title="Hypertext Transfer Protocol">HTTP</acronym> requests</a></strong>. Many browsers still can&rsquo;t handle more than two or four requests at a time. Keep the number of files down, your website will be faster.</p>

<p>There are several techniques with the aim to reduce the number of files:</p>

<ol><li id="inline-css"><p><strong>&ldquo;<q>A single large file is fastest.</q>&rdquo;</strong> (<cite>Nate Koechley</cite>) That&rsquo;s why Yahoo! <em>apparently</em> has such an amount of <a href="http://www.robertnyman.com/2007/01/24/with-these-web-sites-would-you-say-the-web-standards-war-is-won/">inline <acronym title="Cascading Stylesheets">CSS</acronym></a>. They found out <a href="http://yuiblog.com/blog/2007/01/04/performance-research-part-2/" title="YUI Blog: Performance research, part 2: browser cache usage &ndash; exposed!">browser caching</a> is not as effective as they thought, in particular not on a user&rsquo;s start page. So they deliver &ldquo;inline&rdquo; <acronym>CSS</acronym>. Actually writing inline <acronym>CSS</acronym> is a maintenance nightmare, but delivering <acronym>CSS</acronym> content inline doesn&rsquo;t mean the files can&rsquo;t have separate lives on the server: concatenate the files with a server side technique of your choice.</p>
<p><strong>Update:</strong> A couple of months later <a href="/2007/performance-2/#rule-8">Nate explained that further</a>: when your page is likely to be a user&rsquo;s start page, caching plays a minor role, thus &ldquo;inline&rdquo; <acronym>CSS</acronym> is faster. Otherwise use external files, aggregate them, and make sure they are cached (see below).</p></li>
<li id="enforce-caching"><p><strong>Enforce caching.</strong> Another <a href="http://www.bazon.net/mishoo/articles.epl?art_id=958"><acronym title="Internet Explorer">IE</acronym> bug</a> prevents image caching. Add the following to your <code>.htaccess</code>, <code>httpd.conf</code> or <code>vhost.conf</code> settings:</p>
<ol class="code">
<li><code>&lt;IfModule mod_expires.c&gt;</code></li>
<li class="indent"><code>ExpiresActive On</code></li>
<li class="indent"><code>ExpiresByType image/jpg &quot;access plus 1 day&quot;</code></li>
<li class="indent"><code>ExpiresByType image/jpeg &quot;access plus 1 day&quot;</code></li>
<li class="indent"><code>ExpiresByType image/gif &quot;access plus 1 day&quot;</code></li>
<li class="indent"><code>ExpiresByType image/png &quot;access plus 1 day&quot;</code></li>
<li><code>&lt;/IfModule&gt;</code></li></ol></li>
<li id="background-images"><p><strong>Reduce the number of background images</strong> with techniques like <a href="http://www.alistapart.com/articles/sprites/">CSS Sprites</a> or <a href="http://www.alistapart.com/articles/slidingdoors/">Sliding Doors</a>. Instead of four images of rounded corners you <a href="http://www.fiftyfoureleven.com/sandbox/sliding-doors-one-image/" title="Example">only need one</a> and get the mouseover state for free! The green download button on <a href="http://www.mozilla.com">mozilla.com</a> is based on that technique. And <a href="http://www.yahoo.com">Yahoo!</a> uses <acronym>CSS</acronym> Sprites to combine a huge number of icons.</p>

<p><img src="/wp-content/uploads/2007/01/mozilla-button.jpg" class="centered screenshot" width="300" height="149" alt="Download button on mozilla.com using the Sliding Doors technique" /></p>

<p>Please note this approach is only for <em>decorational background images</em> that degrade gracefully. <del>It&rsquo;s not for <code>img</code> elements.</del> <ins>Be careful when you use it for <a href="/2007/foreground-sprites/">foreground images</a>.</ins> And if text comes as a graphical representation, it can become inaccessible for screen reader users, zoom readers, or people with stylesheets switched off. Use real text instead.</p>

<p>Also note changing the <code>background-position</code> causes <acronym>IE6</acronym> to flicker, related to the caching bug above. To avoid it, simply add the following:</p>
<ol class="code">
<li><code>&lt;script type=&quot;text/javascript&quot;&gt;</code></li>
<li class="indent"><code>try { document.execCommand(<span class="codeSpace">&nbsp;</span>&quot;BackgroundImageCache&quot;, false, true); } catch(e) {};</code></li>
<li><code>&lt;/script&gt;</code></li></ol></li>
<li id="file-aggregation"><p><strong>Aggregate files.</strong> Ed Eliot wrote a nice <a href="http://www.ejeliot.com/blog/72" title="Automatic merging and versioning of CSS/JS files with PHP">script to merge JavaScript or <acronym>CSS</acronym> files</a>, bonus respect for the advanced versioning and caching features.</p>

<p>But remember the cases when it doesn&rsquo;t make sense to merge <acronym>CSS</acronym> files: your <acronym title="Internet Explorer">IE</acronym> bugfixes still belong in conditional comments. If you use the <code>@import</code> rule to filter antique browsers from getting advanced styles, you can&rsquo;t drop it. And if you want to merge stylesheets for different media (<abbr title="for example">e.g.</abbr> print), make sure the code is enclosed in something like</p>


<ol class="code">
<li><code>@media print {</code></li>
<li class="indent"><code>/* style sheet for print goes here */</code></li>
<li><code>}</code></li></ol>


<p>In an <a href="http://www.ejeliot.com/blog/73" title="Adding JSMin to the CSS/JS merging script">updated version</a> Ed added <a href="http://javascript.crockford.com/jsmin.html">JSMin</a> to strip comments and excess whitespace. JSMin works like a charm for JavaScript files. But it cuts a few space characters too much so that the syntax of <acronym>CSS</acronym> selectors changes <del>therefore for now I have abandoned the idea to compress them too</del>. <ins>See <a href="#comment-6045">Jens Meiert&rsquo;s comment</a> below for a recommendation to minimize <acronym>CSS</acronym>.</ins></p>

<p>His original code requires the C version of JSMin with PHP <code>safe_mode</code> turned off. If you prefer a pure PHP version, get the <a href="http://javascript.crockford.com/jsmin2.php.txt">PHP version of JSMin</a> and my <a href="/examples/combine-jsmin.phps" type="text/plain">adapted version of the script</a>.</p>
</li></ol>

<p>I&rsquo;m still in awe how fast one of my own websites became! Thanks to the guys at Yahoo! for the inspiration and for most of the research this article is based upon. Even JSMin was written by an employee of Yahoo! Speaking about Yahoo! employees: <a href="http://wait-till-i.com/" title="Christian Heilmann" rel="met colleague">Chris</a>, I hope there are still enough topics for your <a href="http://www.thinkvitamin.com/features/dev/enhance-your-page-performance" title="Chris Heilmann: Enhance your (page) performance!">Vitamin article</a>. I wanted to write about performance anyway, and to my surprise I <a href="http://www.robertnyman.com/2007/01/24/with-these-web-sites-would-you-say-the-web-standards-war-is-won/#comment-29959">read yesterday</a> that you have similar plans. See ya in <a href="/2007/brain-food/#e-accessibility" title="First European e-Accessibility Forum">Paris</a>. <img src="http://learningtheworld.eu/wp-includes/images/smilies/icon_wink.gif" alt=";)" class="wp-smiley" /> </p>
]]></content:encoded>
			<wfw:commentRss>http://learningtheworld.eu/2007/performance/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
	</channel>
</rss>
