Is it safe to use base64 encoded images for web, Advantages and Disadvantages?

 ̄綄美尐妖づ 提交于 2019-12-30 17:23:30

问题


Is it safe to use base64 encoded images for web design, How does it compare in performance? Advantages and Disadvantages?


回答1:


A base64 stream is about 33% heavier than a binary one (not taking into account the gzip compression over http that you have in place if you're serious about performances).

If you put the base64 image directly in a page, it won't be cached separately. So it will be heavy for all pages using this image instead of being cachable with URL as key. You may think that it helps keeping the request number low but in fact it's useless in normal cases where users have yet the images in their cache (if you have many images, prefer css sprites to lower the number of requests).

I don't think there is a reason to use a base64 image except for when addressing a specific technical issue, like sending an image in json, or saving only one html file - and then check you really need to use the base64 image.



来源:https://stackoverflow.com/questions/11188769/is-it-safe-to-use-base64-encoded-images-for-web-advantages-and-disadvantages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!