When to consider base64 (DATA: URI) images?

前端 未结 3 1725
不思量自难忘°
不思量自难忘° 2021-02-06 09:40

What are the factors that should trigger thinking about switching images over to Base64 embedded in CSS?

There seems to be a lot of generic pro/con type things out there

3条回答
  •  滥情空心
    2021-02-06 10:31

    When you can use css-sprites, that's definitely better.

    One particular case in which I prefer base64 DATA URI is when we have a small image file which will be used as background with repeat-x or repeat-y. Since repeat doesn't play well with css-sprites, you need to use a single image as a source. In this case, I find that using the base64 version is a better alternative which saves you a request to your web server.

提交回复
热议问题