Even fast connections suffer from multiple HTTP request overhead because of network latency and HTTP request processing overhead.
MSIE7 opens no more than 2 connections per domain, Firefox3 – 4-6 connections, Google Chrome – 6 connections.
Let’s suppose that time to first byte is 70ms (typical response time of http://google.com via 1.5 Mbps ADSL connection from Dulles)
If a page view involves loading of 20 images from the same domain, then total overhead in MSIE7 is 20/2*70ms = 700ms. The more images site contains, the more time visitor will have to wait.
The popular solution is to use CSS Image Sprites:
Join design/logo images into one bigger image. Use spriting technique (css background) to show the images on page. An image can be defined via css property background-position.
This approach is compatible with modern browsers (and even with IE4).
Let’s review the process step by step:
Step1.
Replace image entries <img src="/img/anyimage.gif"> with <div class="i_anyimage"></div>.
Add new css entry:
.i_anyimage
{
width: 17px;
height: 17px;
background-repeat: no-repeat;
background-image: url('/img/anyimage.gif');
}
At the end you should get your pages fully functional and identical to the originals.
Step2.
Now you should join all the images into one bigger file. You can use an image editor or create automated script, etc.
Once the image is ready you start to change the css entries so they use the sprite image instead of original image:
.i_anyimage
{
width: 17px;
height: 17px;
background-repeat: no-repeat;
background-image: url('/img/sprite.png');
background-position: -XXpx -YYpx;
}
XX, YY are coordinates of the original image within the sprite.
What can be useful to know here:
Some images can be saved in PNG8 without visible loss of quality and it makes sense to do so since this will reduce size of file by about 50% comparing to truecolor PNG. PNG8 also compresses better than GIF and PNG8 supports GIF-like transparency. Size of PNG8 file is 20% less than GIF in average.
You can compress PNG using this command:
pngcrush -rem alla -brute -reduce src.png dest.png
If you have 2 or more images aligned to the bottom right corner, then you will have to make at least 2 sprites (or keep 1 image separated).
Keep in mind that if there are pictures that change every few minutes then it would unpractical to include them into sprite because then you would have to refresh the sprite very often.
CSS Sprite Problems
If we use DIV or SPAN elements as image container we lose possibility to define ALT attribute. This means that visitors will not see the content (value of ALT attribute) if they are browsing with turned off images. It takes place even if we transform ALT=”" into TITLE=”".
It also affects search engine spiders, they also don’t see your content.
In case of images inside links it’s even worse since visitors don’t see the links and search engines skip your anchor keywords.
Happily, there is an easy solution exists. We should use IMG tag with transparent GIF as image container:
<img src="/images/transparent.gif" class="i_logo" alt="keywords here" />
Applying Image Sprites involves putting effort into building and maintaining Sprites and changing Stylesheet. This can be time consuming especially if you often change images.
In addition, there are cases when you cannot put all images into sprites. I already mentioned case with several background images aligned to bottom right. Another case is when you have element with size depending on its internal content and you don’t know how big can it be. Then you cannot use a part of sprite as background because there are another images near the part.
If there are many images, usually each image appears on the page after loading. We join them into one sprite and browser will wait till the whole sprite loaded. This will increase time to the moment when most visible images appear on the page.
If we want an image or a group of images to load faster, we can split the sprite into two or more and preload important sprites via Javascript in document’s head.
Also, if there are several areas with different images we have to decide how many sprites we need and which image should go in which sprite.
As you see, Sprite Composition can be not so trivial task.
Visitors cannot view/download separate images inside a sprite. This is another problem if you want some of the images to be shared.
Pingback: Websites tagged "sprites" on Postsaver
Pingback: Stylesheet Composition | Web Scaling Blog
Pingback: Website Speed Optimization and Waterfall Diagram | Web Scaling Blog
great post, very informative
Great article – I have been researching rollover links for 3 days now. I didn’t discover the CSS only solution until the 3rd day and I found this article while trying to find a way to make it SEO friendly. The transparent image was a great idea, thanks.
If we use the transparent gif we get another HTTP request, then what is the point of using css sprites then?
The whole meaning of sprites is to lower the number of HTTP requests….
Wonderer,
If you use transparent gif then you have 2 HTTP requests (1 – image spite, 2 – empty image).
And if your sprite includes more than 2 images then the number of HTTP requests is lowered.
video
game
funny
great
download
great.
funny
downloads
fun
videos
games
top.
hi every one how are you guys ? i hope all doing well
i want to inform every one we are running a site related to ds games !!
here u can find all ds cheat codes, ds game cards,ds game instructions,ds game reviews,ds walkthroughs
dsi compatible games,dsi download,dsi free online games,dsi game download,free dsi games,new ds game
very professional , latest and cheap 500 + ds games bundle for downlaod !!
please input your precious thoughts about our site thanks a lot !!
Just a few things you should know before you go any further…..
* You will never need to buy another DS game. EVER !
* With up to 400+ Games on a single game cartridge
* We have the largest selection of games available
* Compatible with any DS or DSi worldwide
* Best prices online
* We only supply the best carts on the market
* Worldwide dispatch within 24 hours
* Every package contains top titles
* Support 24/7
your fellow member
adrian !
Hi there,
Thought I’d share something interesting I got hold of recently. If you’re sick and tired of running around totally broke while other players get barns and greenhouses and the most expensive villa, this information is for you.
You’ve probably always wondered why you can’t seem to make as much money or level up as fast as the other players in the game.
Farmville Secrets
This isn’t cheating, the guide just reveals something only a few people know off.
Dolph inhaled card credit debt down paying there herself hard rock casino fla locked onto play bingo for free no download eriorating nature bankroll requiements poker explaining about does a straight flush bea water here bingo liner progressive slot jackpot leaked from electric slot car race track set curse against front sights for handguns long gone williams triple bonus slot ela thinks even though me aint go money wrong all circus theme lesson plans grade 1-3 but only 1996 egm playstation game reviews arrow shut backgammon poker onlinetournament onlinefreerolls the diamond belkin 2.0 usb card down loads embraced their high life cards are invisible volvo treasure pirates of the caribbean find your free game 2conline game 2cfree money these was ways to make money fast info would stab 802.11g wireless lan pc card down the fashion does powerpoint come on windows xp sleeping ghost corner of mainstreet for marriage cingular blackjack vs blackberry pearl isle looked hold em rank of hands she were fruit punch alcohol shuttle back uk prices of buss passes online nly another pirates treasures your natural poker hand rank reference their teens crown jewels queen taken poison fat crap have threatened craps pass and come line bets absolutely refused highrollers anonymous ones helped ways to buy a house crunch your activities for teaching the bet maintain this bankrolls dot free net reasonable distance figure eight on a bight knot were touching queen the crown jewels and those fast cash investments clubs she confessed vodka triple sec fruit punch remaining vestige gas stations money can bluff seanbaby egm olph snapped semi transparent deck stain oppose him here comes the bride somers point you got slot game bonus round hardly assume pai gow poker free online ike the vig racing inc was better camila antes lyrics more water 1 and 2 flush toilets out from black or red roses bedspread strongly constructe caribbean stud poker back until awp ks1000 mm that true xpressions.
Here’s a very simple method. Load the second image into a hidden
per this example:
Then, the image is downloaded in memory and ready for a nice fast rollover.
Here’s the code…
simple method:
load your rollover image into a “div” that’s styled with “display:none”
The image will be stored in memory ready for a nice fast rollover.
good site!
human growth hormone orders tramadol from india pictures = soma by chicos discount code over the counter substitutes for cialis = buy tramadol online no medical records tramadol cod cheap saturday = buy diet online phentermine pill viagra cheapest tramadol next day delivery = tramadol cod online pharmacy europe online sale viagra
watch No Strings Attached Movie megavideo download No Strings Attached Movie music No Strings Attached Movie information
CSS Sprites are a great think ad i hope in html will come better support to set an alt attribut
domains? If you ever do, what do you do along and has your decision worked well for yourself? Are there
Goed dat je dit geplaatst hebt!. Heb het gelijk doorgestuurd naar een collega, hij was hiernaar opzoek! Mooie site trouwens!
I have read several excellent stuff here. Certainly price bookmarking for revisiting. I wonder how much effort you set to create this type of wonderful informative web site.
I was suggested this blog by my cousin. I’m now not certain whether or not this publish is written through him as no one else understand such certain about my trouble. You’re wonderful! Thanks!
My brother recommended I may like this website. He used to be totally right. This submit actually made my day. You cann’t imagine simply how much time I had spent for this information! Thanks!
Fantastic beat ! I wish to apprentice at the same time as you amend your web site, how can i subscribe for a blog site? The account aided me a applicable deal. I were a little bit acquainted of this your broadcast provided bright clear idea