I recently worked on a project where we made an image sprite for some 20 images we had.
We created multiple sprites for different displays and used like this:
.something {
background-image: url("img/sprite.png");
}
@media only screen and (min-device-pixel-ratio:1.6) {
.something {
background-image: url("img/sprite@2x.png");
}
}
Now, over the course of the project, as the images kept changing, we had to re-photoshop the different sprite versions.
This is a big problem with sprites.
With every new change there's an overhead of editing the different sprite versions, replacing them and then doing a cache bust for the CSS. Not to forget setting the position for the slightest change and photoshop blur that occurs every now and then.
There are so many tiny things to care for and adjust while using sprites. All in the name of performance.
This question comes into my mind.. Is any of this "optimization" really necessary?
Until recently, using image sprites was really useful to optimize the loading (single resource fetch, on a single connection) That said, with the support of HTTP2, this is no longer an issue. So the answer to your question might really depends on your setup. If you're still using http1.1 connections and have a huge number of images, then css sprites is the way to go (there's tools to automate their creation). If you already moved to http2 (and your primary target use modern browsers), then you might start considering using simple images without having to pay a huge performance bill.
Nirmalya Ghosh
Developer
Yes. Of course, it's reasonable given that it reduces the number of connections (smashingmagazine.com/2010/03/css-sprites-useful-t…).
You can also make use of services like http://spritegen.website-performance.org/ to help you regenerate sprites in case you have made changes to your sprites or modified one of the images.
I would suggest you to go through the article on Smashing Magazine. You will get a better overview about why you should try to avoid using separate images.
As a side note, you can also try using svg.