<?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>sprite &#8211; stoimen&#039;s web log</title>
	<atom:link href="/tag/sprite/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>on web development</description>
	<lastBuildDate>Tue, 13 Feb 2018 08:18:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.0.3</generator>
	<item>
		<title>CSS sprites. Go beyond the limits with base64!</title>
		<link>/2010/02/05/css-sprites-go-beyond-the-limits-with-base64/</link>
		<comments>/2010/02/05/css-sprites-go-beyond-the-limits-with-base64/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 08:10:29 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[base64]]></category>
		<category><![CDATA[Cascading Style Sheets]]></category>
		<category><![CDATA[communication]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Data URI scheme]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[Minification]]></category>
		<category><![CDATA[sprite]]></category>
		<category><![CDATA[Stoyan Stefanov]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[URI scheme]]></category>
		<category><![CDATA[Web design]]></category>
		<category><![CDATA[Web page]]></category>
		<category><![CDATA[web projects]]></category>
		<category><![CDATA[web server]]></category>
		<category><![CDATA[World Wide Web]]></category>

		<guid isPermaLink="false">/?p=1055</guid>
		<description><![CDATA[Why should I optimize CSS? In fact how and why should I optimize CSS is the right question. Actually CSS is simply one ore more files loaded from the server to the client, usually a browser, with CSS specific rules that must be applied by the browser to the web page you&#8217;re seeing. That&#8217;s in &#8230; <a href="/2010/02/05/css-sprites-go-beyond-the-limits-with-base64/" class="more-link">Continue reading <span class="screen-reader-text">CSS sprites. Go beyond the limits with base64!</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2009/04/23/when-you-should-use-base64-for-images/" rel="bookmark" title="When you should use base64 for images">When you should use base64 for images </a></li>
<li><a href="/2010/01/30/optimizing-css-five-simple-steps/" rel="bookmark" title="Optimizing CSS. Five simple steps!">Optimizing CSS. Five simple steps! </a></li>
<li><a href="/2010/01/13/optimizing-the-web-start-with-the-images/" rel="bookmark" title="Optimizing the web. Start with the images!">Optimizing the web. Start with the images! </a></li>
<li><a href="/2011/01/07/more-on-css-optimization/" rel="bookmark" title="More on CSS Optimization">More on CSS Optimization </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>Why should I optimize CSS?</h2>
<p>In fact how and why should I optimize CSS is the right question. Actually CSS is simply one ore more files loaded from the server to the client, usually a browser, with CSS specific rules that must be applied by the browser to the web page you&#8217;re seeing. That&#8217;s in general. Of course there are exceptions when CSS can be inline or added directly to the HTML tags, which is bad practice because thus the HTML markup becomes larger and even worse the browser cannot cache it and than load it quickly. In fact that&#8217;s why usually the CSS of a web page is put in one single file. Primary because that makes only one request to the server and in second hand because it can be cached by the browser.</p>
<p>Just because the nature of the CSS is that firstly it&#8217;s loaded and than executed one of the primary techniques of optimizing it is to make it smaller and therefore load faster. There are several methods of doing so. Enabling GZIP support of the web server and minifying the file are the most common ones. But one of the tricks you cannot optimizing just for second is using the so called CSS sprites.</p>
<h2>CSS sprites</h2>
<p>What are these? To answer this question I&#8217;ll simply try to give you an example. Let&#8217;s assume there are three CSS classes each one with its own background image. This makes four requests to the server. One for the CSS file and one per every background image. But what we&#8217;d like to achieve is to make less requests as we can. Than one of the things we can do is to make one single image and to change only the background-position CSS property to position it on the right place and to make it appear correctly.</p>
<p>Be careful! When you join all of the images into one single CSS sprite you may add one class with that background-image and every other class with only background-position property. Than every DOM element with that background must have both class names. Only than you can be sure the server will make two requests. One for the CSS file and one for the sprite.</p>
<h2>base64 to encode images</h2>
<p>In other hand most of the web projects are pretty big, and unfortunately it&#8217;s too difficult to make only one single sprite just because it&#8217;s too difficult to manage it after the project has become very large. That&#8217;s why mostly in the practice there are several sprites for the main components. But the problem is that again there are more HTTP requests.</p>
<h3>Is there any way to make only one request?</h3>
<p>Yes there is. Simply by converting your CSS sprite into a base64 encoded image. In breve base64 is an encoding where you can practically make any data into a string. Thus the image can be represented by a string containing the same information as the image. Hopefully most of the browser, except of course MSIE, does read the so called data urls, or:</p>
<blockquote>
<pre>&lt;img src="data:image/png;base64,..... " /&gt;</pre>
</blockquote>
<p>and that&#8217;s enough to get started with base64 and the single request. The sprite has become a string!</p>
<h2>CSS and base64</h2>
<p>The natural question is now how to merge all this? You now have one CSS file with one or more sprites. Than you can convert them into a base64 encoded strings and put them all into the CSS.</p>
<p>There is a problem, of course, what happens with MSIE. As I said before MSIE doesn&#8217;t read base64 encoded images. Hopefully there is a solution described very well by <a href="http://phpied.com/" target="_blank">Stoyan Stefanov</a> in his <a href="http://www.phpied.com/data-uris-mhtml-ie7-win7-vista-blues/" target="_blank">blog post here</a>.</p>
<h2>Finally &#8230;</h2>
<p>now there is only one request and everything works pretty fine. This technique can be really helpful to someone who&#8217;s trying to optimize the CSS performance to the limits.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2009/04/23/when-you-should-use-base64-for-images/" rel="bookmark" title="When you should use base64 for images">When you should use base64 for images </a></li>
<li><a href="/2010/01/30/optimizing-css-five-simple-steps/" rel="bookmark" title="Optimizing CSS. Five simple steps!">Optimizing CSS. Five simple steps! </a></li>
<li><a href="/2010/01/13/optimizing-the-web-start-with-the-images/" rel="bookmark" title="Optimizing the web. Start with the images!">Optimizing the web. Start with the images! </a></li>
<li><a href="/2011/01/07/more-on-css-optimization/" rel="bookmark" title="More on CSS Optimization">More on CSS Optimization </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/02/05/css-sprites-go-beyond-the-limits-with-base64/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Optimizing CSS. Five simple steps!</title>
		<link>/2010/01/30/optimizing-css-five-simple-steps/</link>
		<comments>/2010/01/30/optimizing-css-five-simple-steps/#respond</comments>
		<pubDate>Sat, 30 Jan 2010 07:04:40 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[Cascading Style Sheets]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[Google Inc.]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[Minification]]></category>
		<category><![CDATA[Software engineering]]></category>
		<category><![CDATA[software minifies]]></category>
		<category><![CDATA[sprite]]></category>
		<category><![CDATA[Steve Souders]]></category>
		<category><![CDATA[Style sheet]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[Web design]]></category>

		<guid isPermaLink="false">/?p=872</guid>
		<description><![CDATA[In the spirit of the optimization wave this post is about CSS optimization. There are some simple rules that you can apply. I’m pretty sure most of us have already been familiar with that list, but you never know. 1. Minify As the JavaScript the CSS also can be minified. This only strips every character &#8230; <a href="/2010/01/30/optimizing-css-five-simple-steps/" class="more-link">Continue reading <span class="screen-reader-text">Optimizing CSS. Five simple steps!</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/01/18/what-if-your-site-doesnt-use-all-of-the-css-selectors/" rel="bookmark" title="What if your site doesn&#8217;t use all of the CSS selectors?">What if your site doesn&#8217;t use all of the CSS selectors? </a></li>
<li><a href="/2011/01/07/more-on-css-optimization/" rel="bookmark" title="More on CSS Optimization">More on CSS Optimization </a></li>
<li><a href="/2010/02/15/css-selectors-new-look-over-them/" rel="bookmark" title="CSS selectors &#8211; new look over them">CSS selectors &#8211; new look over them </a></li>
<li><a href="/2010/02/05/css-sprites-go-beyond-the-limits-with-base64/" rel="bookmark" title="CSS sprites. Go beyond the limits with base64!">CSS sprites. Go beyond the limits with base64! </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>In the spirit of the optimization wave this post is about CSS optimization. There are some simple rules that you can apply. I’m pretty sure most of us have already been familiar with that list, but you never know.</p>
<h3>1. Minify</h3>
<p>As the JavaScript the CSS also can be minified. This only strips every character that makes the traffic bigger. As you know a well constructed and pretty looking CSS file consists of many new lines, tabs and spaces. Almost every software minifies the CSS by simply removing them. Some of the programs go even further with replacements of different parts of the code considered to be not efficient.</p>
<h3>2. Use effective selectors</h3>
<p>Some CSS selectors aren’t really efficient. Imagine something like: body div a just to describe only one specific link. That’s really bad. Better practice is to replace that line with something like a.my-class and to replace the a tag into the DOM with that class name. That will be far more effective. Actually if you’re wondering how to find such bad selectors, there’s a tool by Google called Page Speed that’s a Firebug’s plugin and can extract a list of all bad selectors.</p>
<h3>3. Inheritance</h3>
<p>CSS is really powerful when dealing with inheritance. That’s something that is not some clear but however really powerful. This technique is in the basics of the next rule.</p>
<h3>4. Sprites</h3>
<p>I’ve written already about CSS sprites. This is nothing new, but be careful when making a new site’s layout. CSS sprites spend you HTTP request and that’s rule number one according to Steve Souders’ list of optimization.</p>
<h3>5. Separate logic</h3>
<p>Sometimes developers put the site logic in only one file that become to large. Be aware of that. This is hard to maintain and you load things that you don’t need.</p>
<p>That’s a really short list of what you can do with CSS to speed the site up. I hope that can help someone when dealing with cascading style sheets.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/01/18/what-if-your-site-doesnt-use-all-of-the-css-selectors/" rel="bookmark" title="What if your site doesn&#8217;t use all of the CSS selectors?">What if your site doesn&#8217;t use all of the CSS selectors? </a></li>
<li><a href="/2011/01/07/more-on-css-optimization/" rel="bookmark" title="More on CSS Optimization">More on CSS Optimization </a></li>
<li><a href="/2010/02/15/css-selectors-new-look-over-them/" rel="bookmark" title="CSS selectors &#8211; new look over them">CSS selectors &#8211; new look over them </a></li>
<li><a href="/2010/02/05/css-sprites-go-beyond-the-limits-with-base64/" rel="bookmark" title="CSS sprites. Go beyond the limits with base64!">CSS sprites. Go beyond the limits with base64! </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/01/30/optimizing-css-five-simple-steps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Optimizing the web. Start with the images!</title>
		<link>/2010/01/13/optimizing-the-web-start-with-the-images/</link>
		<comments>/2010/01/13/optimizing-the-web-start-with-the-images/#respond</comments>
		<pubDate>Wed, 13 Jan 2010 07:30:10 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[base64]]></category>
		<category><![CDATA[Cascading Style Sheets]]></category>
		<category><![CDATA[E-mail]]></category>
		<category><![CDATA[faster site]]></category>
		<category><![CDATA[gif]]></category>
		<category><![CDATA[Graphics file formats]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[Program optimization]]></category>
		<category><![CDATA[sprite]]></category>
		<category><![CDATA[Stoyan Stefanov]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[Usenet]]></category>
		<category><![CDATA[Web design]]></category>
		<category><![CDATA[web project]]></category>
		<category><![CDATA[web site optimization]]></category>
		<category><![CDATA[Yahoo! Inc.]]></category>

		<guid isPermaLink="false">/?p=873</guid>
		<description><![CDATA[Common question when speaking about web site optimization is: where should I start. As I mentioned before almost every technology used in the building of a web project can be improved. The bad news is that this improvement needs effort and when it comes to changing some code that’s already written that’s bad. The good &#8230; <a href="/2010/01/13/optimizing-the-web-start-with-the-images/" class="more-link">Continue reading <span class="screen-reader-text">Optimizing the web. Start with the images!</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/01/30/optimizing-css-five-simple-steps/" rel="bookmark" title="Optimizing CSS. Five simple steps!">Optimizing CSS. Five simple steps! </a></li>
<li><a href="/2009/04/23/when-you-should-use-base64-for-images/" rel="bookmark" title="When you should use base64 for images">When you should use base64 for images </a></li>
<li><a href="/2010/01/11/what-should-be-optimized-in-one-web-page/" rel="bookmark" title="What should be optimized in one web page?">What should be optimized in one web page? </a></li>
<li><a href="/2010/02/05/css-sprites-go-beyond-the-limits-with-base64/" rel="bookmark" title="CSS sprites. Go beyond the limits with base64!">CSS sprites. Go beyond the limits with base64! </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>Common question when speaking about web site optimization is: where should I start. As I mentioned before almost every technology used in the building of a web project can be improved. The bad news is that this improvement needs effort and when it comes to changing some code that’s already written that’s bad. The good news, as it exists, is that in the most cases most of the traffic of a site comes by images and/or other media and their optimization doesn’t have to deal with coding and can simply be optimized.</p>
<h2>Optimize every image</h2>
<p>The first thing that you can do to improve your site image is to optimize them. Sometimes the files you put on the site as they are JPEG, GIF and PNGs can be improved just by using some software that strips useless information from their headers and using various algorithms to smooth the similar pixels.  As you may know in the case of PNG and GIF this is particularly natural. Stoyan Stefanov a lead Yahoo! developer is know as guru when it comes image optimization. You can check more detailed information about software and tools on his blog here. The reality is that you don’t need extra info into the images, as useless information about the camera, which is often setup into the image header, and when it comes to the web that’s really good. In fact according to some researches this can spend you more than 30% of traffic.<span id="more-873"></span></p>
<h2>Use CSS sprites</h2>
<p>What are CSS sprites? Well you possibly already know. I’ve written some articles about that, so I won’t mention it again, but what’s the point. The CSS sprite usage helps you merge all the images you use into your site into one single image  and to manipulate the site’s outlook only by changing the element background position. That’s really nice, it requires a bit concentration to track different elements background, but it’s not difficult at all. In fact there are some tools that can help to automate this. The good thing is that thus you replace all the background images with one single image and thus with one single request. So if you’ve one CSS file with twenty background images by using one CSS sprite there is only two requests instead of twenty one requests. Even more, you can go even further with this optimization technique and to replace the CSS sprite call by http by built into the CSS file base64 string. With that simple trick you got only one! request. Yes this becomes more difficult to maintain, but it’s really close to extreme optimization.</p>
<h2>Use base64 to improve http request number when possible</h2>
<p>That’s not a news, but however if you like to switch from multiple to one request the answer is base64. The good thing with base64 is that it can send to the client multiple images with single request and it natively eliminates the extra info from the image you convert. It has to be used with care, because sometimes even if it’s slower using multiple requests via HTTP for the images gives the user the feeling of faster site, just because the user sees response from the server earlier.</p>
<p>That’s all I can say about image optimization in one site. You can search in detail about tools and software, as well as other techniques explained here.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/01/30/optimizing-css-five-simple-steps/" rel="bookmark" title="Optimizing CSS. Five simple steps!">Optimizing CSS. Five simple steps! </a></li>
<li><a href="/2009/04/23/when-you-should-use-base64-for-images/" rel="bookmark" title="When you should use base64 for images">When you should use base64 for images </a></li>
<li><a href="/2010/01/11/what-should-be-optimized-in-one-web-page/" rel="bookmark" title="What should be optimized in one web page?">What should be optimized in one web page? </a></li>
<li><a href="/2010/02/05/css-sprites-go-beyond-the-limits-with-base64/" rel="bookmark" title="CSS sprites. Go beyond the limits with base64!">CSS sprites. Go beyond the limits with base64! </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/01/13/optimizing-the-web-start-with-the-images/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>sprite usage and website optimization</title>
		<link>/2009/06/21/sprite-usage-and-website-optimization/</link>
		<comments>/2009/06/21/sprite-usage-and-website-optimization/#comments</comments>
		<pubDate>Sun, 21 Jun 2009 12:49:57 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[sprite]]></category>
		<category><![CDATA[spritegen]]></category>

		<guid isPermaLink="false">/?p=617</guid>
		<description><![CDATA[What&#8217;s a sprite? When a website is developed common scenario is to put all of your images used in the UI in a .css file. Yes some did not use it, which I think is too much old school, but however maybe 99.9% did make it that way. In fact in nowadays sites we&#8217;ve more &#8230; <a href="/2009/06/21/sprite-usage-and-website-optimization/" class="more-link">Continue reading <span class="screen-reader-text">sprite usage and website optimization</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/02/05/css-sprites-go-beyond-the-limits-with-base64/" rel="bookmark" title="CSS sprites. Go beyond the limits with base64!">CSS sprites. Go beyond the limits with base64! </a></li>
<li><a href="/2009/10/06/css-sprites-common-mistakes/" rel="bookmark" title="CSS Sprites &#8211; common mistakes">CSS Sprites &#8211; common mistakes </a></li>
<li><a href="/2010/01/13/optimizing-the-web-start-with-the-images/" rel="bookmark" title="Optimizing the web. Start with the images!">Optimizing the web. Start with the images! </a></li>
<li><a href="/2011/01/07/more-on-css-optimization/" rel="bookmark" title="More on CSS Optimization">More on CSS Optimization </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>What&#8217;s a sprite?</h2>
<p>When a website is developed common scenario is to put all of your images used in the UI in a .css file. Yes some did not use it, which I think is too much old school, but however maybe 99.9% did make it that way. In fact in nowadays sites we&#8217;ve more and more rounded corners, more alpha in our images. But what&#8217;s a sprite at all.</p>
<p>Well imagine you&#8217;ve 20 of these images requested in you .css file, if we suggest we&#8217;ve only one stylesheet file. Than when your page is rendered into a browser there must be 20 requests to the server for those images. And so many requests may really slow down your page load. Using only one image with correct</p>
<blockquote>
<pre>background-image
background-position</pre>
</blockquote>
<p>properties in you css make your site load really fast.<span id="more-617"></span></p>
<h2>What&#8217;s website optimization?</h2>
<p>Most of the beginners think that a website is always fast. That&#8217;s true until you start making really big sites. Like Youtube, Vimeo, Yahoo, etc. Take a look at their css files and the background images in them. Yes, they are using sprites &#8211; those big images containing all of the background needed for the page. And than the page load may become much faster.</p>
<h2>How a sprite can change my load time?</h2>
<p>In my case the site loaded for 4 to 5 seconds on a normal speed connection. Than only by making a sprite from our 10 images in the background, it became between 3 and 4 sec. That&#8217;s 20%, and 1 second is not so bad in todays&#8217; web space.</p>
<h2>How to make it?</h2>
<p>You must make your background images as one sprite. At all that may become good practice for the future where for sure there will be only that way. OK, but how I can make it. Well you can generate it online simply by using something like <a title="Sprite Generator" href="http://spritegen.website-performance.org/" target="_blank">http://spritegen.website-performance.org/</a> or you can make it alone with some image manipulation programe as GIMP or Adobe Photoshop, it&#8217;s up to you.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/02/05/css-sprites-go-beyond-the-limits-with-base64/" rel="bookmark" title="CSS sprites. Go beyond the limits with base64!">CSS sprites. Go beyond the limits with base64! </a></li>
<li><a href="/2009/10/06/css-sprites-common-mistakes/" rel="bookmark" title="CSS Sprites &#8211; common mistakes">CSS Sprites &#8211; common mistakes </a></li>
<li><a href="/2010/01/13/optimizing-the-web-start-with-the-images/" rel="bookmark" title="Optimizing the web. Start with the images!">Optimizing the web. Start with the images! </a></li>
<li><a href="/2011/01/07/more-on-css-optimization/" rel="bookmark" title="More on CSS Optimization">More on CSS Optimization </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2009/06/21/sprite-usage-and-website-optimization/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
	</channel>
</rss>
