Is it safe to use base64 encoded images for web, Advantages and Disadvantages?(将 base64 编码的图像用于 Web 是否安全,优点和缺点?)
问题描述
在网页设计中使用 base64 编码的图像是否安全,它的性能比较如何?优缺点?
Is it safe to use base64 encoded images for web design, How does it compare in performance? Advantages and Disadvantages?
推荐答案
base64 流比二进制流大约重 33%(不考虑 gzip 压缩在 http 上,如果你是认真的表演).
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).
如果你把base64图片直接放在一个页面中,是不会单独缓存的.因此,对于使用此图像而不是使用 URL 作为键可缓存的所有页面来说,这将是沉重的.您可能认为它有助于保持较低的请求数,但实际上在用户缓存中还有图像的正常情况下它是无用的(如果您有很多图像,请使用 css sprite 来减少请求数).
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).
我认为没有理由使用 base64 图像,除非解决特定的技术问题,例如以 json 格式发送图像,或仅保存一个 html 文件 - 然后检查您是否真的需要使用 base64图片.
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.
这篇关于将 base64 编码的图像用于 Web 是否安全,优点和缺点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将 base64 编码的图像用于 Web 是否安全,优点和缺点?
基础教程推荐
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
