Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it a good practice using an animated gif as CSS sprites? [closed]

I have a website that pops-up animated icons when you mouseover them

But i think that maybe it could result in poor graphical performance from the browser. I could put animated icons in a sprite, and not-animated icons in another, but what is the point? in that way sprites stop being useful. Do you recommend using a script that animate the icons placed in the sprite manually? What is your recommendation? Since i need a good performance.

like image 994
yukatta Avatar asked Jan 16 '13 23:01

yukatta


2 Answers

Don’t guess, test! Seriously. As long as the animated gif is of reasonable dimensions, I doubt it’ll be a big problem. However, the best way to find out is to try it. Try using Chrome or Safari’s Web Inspector to profile page load times with the various strategies (no animation, animated icons in a separate file, everything in one image), and see which performs the best. If there’s not much difference, choose the easiest one. You can always change it later if performance becomes an issue.

like image 196
marcus erronius Avatar answered Sep 19 '22 13:09

marcus erronius


The gif compression format is a tricky one because all of the blank space isn't treated like it would be in a jpg or png (bitwise). However as the number of animations increases and the number of colors increases, the gif format will begin to break down. What you should do is test the individual sizes against the size of the sprite image. The performance of moving the sprite shouldn't really be an issue at all, but as other answers have said you'll have to test it with different browsers and form factors.

like image 27
Joel Etherton Avatar answered Sep 18 '22 13:09

Joel Etherton