Is it appropriate to use a sprite picture or to convert it to base64 for a small picture?

I have 45 small images, each of which is about 1-3kb, which needs to be displayed once on the page. Whether I make a sprite image to display with a background image or directly convert it to base64 and display it with an img tag, which has better performance. Please analyze it

Jun.14,2021

your situation should be better than sprite. One card is 2k, there is also 90k, a load can be cached locally. Because html is generally not cached, img has to be reloaded every time you put it. In addition, bese64 will increase the volume by about 1 stroke 3.
generally speaking, I am a sprite for a whole set of small icons, and some scattered ones that are not in the whole set will use a base64. A project with a total of several small icons will also use a base64


. It is hard to say that a sprite image integrates multiple small images into a large image, and there is an asynchronous request to fetch an image. Base64 is to attach resources directly to css or html, without additional requests, but css or html files become larger. To sum up, relatively speaking, when loading a large image, the performance of the sprite may be better (the html page is faster), and vice versa is base64.


use the img tag to display sprite images? No one seems to do this. How do you locate background if you have position,img? Of course, maybe the latest technology can implement

Menu