开发者

Are large CSS sprites a good idea?

开发者 https://www.devze.com 2023-03-20 00:56 出处:网络
I have a large CSS Sprite which takes about 3 seconds to load on my high-speed internet. I want to know if th开发者_JAVA技巧is is a good idea or not.

I have a large CSS Sprite which takes about 3 seconds to load on my high-speed internet. I want to know if th开发者_JAVA技巧is 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.


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.


If your sprite is that big, I would recommend to split your images into logic groups and save them into several sprites (think of 2-4). If not all split sprites are displayed at once on a page, the page load will increase.

0

精彩评论

暂无评论...
验证码 换一张
取 消