There are at least two ways to use an image in CSS:
-
with an HTTP request;
url(/path/to/image.png)
-
with a data URL.
url(data:image/png;base64,BASE64_ENCODED_DATA_HERE)
But I was wondering, as base64-encoded data takes 33% more space, therefore 33% more time to load, is it worth it, or should I just make an HTTP request–using a sprite if there’re several images?
A separate request is almost always preferable because with
data:URIs,it doesn’t work in older IEs and is limited to 32k in IE8
it can be argued that it goes against separation of styling and content
Style sheet files get blown up, which may cause trouble if the browser’s developers never expected CSS files to reach these kinds of sizes
I would use it only when there is no other choice.