Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are large CSS sprites a good idea?

I have a large CSS Sprite which takes about 3 seconds to load on my high-speed internet. I want to know if this is a good idea or not.

On top of this, I also want to know if I should display a smaller image of just one bit of the sprite will the actual sprite is loading. Although this means two HTTP requests instead of one, I was wondering if it would make a better UI/user experience, if I made the overlay-ed disappear when the document has loaded.

like image 940
drnessie Avatar asked Jul 11 '11 19:07

drnessie


1 Answers

How large is large?? 3 seconds seems absurd. If you're loading every-image-under-the-sun then no, it's not a good idea. You may also need to look into image optimization (what format is it currently in? Can you post the sprite?)

Basically it's a trade-off. If you're using 1/2 of the images in the sprite on your page, it's fine because you get more of a gain through the fewer HTTP connections then you do a waste for the unused images. If you're using 1% of the images in the sprite, it's not worth it.

As far as your 2nd question goes -- absolutely do that if the sprite needs to be as large as it currently is. You'll see very little loss due to loading one extra small image. The point of sprites is to reduce HTTP connections from 100->10, for example. 10->11 isn't a big deal.

like image 127
Nobody Avatar answered Sep 21 '22 05:09

Nobody