Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

使用 base64 图片的优缺点 #100

Open
nmsn opened this issue Sep 26, 2023 · 1 comment
Open

使用 base64 图片的优缺点 #100

nmsn opened this issue Sep 26, 2023 · 1 comment

Comments

@nmsn
Copy link
Contributor

nmsn commented Sep 26, 2023

No description provided.

@nmsn nmsn added the 浏览器 label Sep 26, 2023
@nmsn
Copy link
Contributor Author

nmsn commented Sep 26, 2023

优点

  1. 能够节约一个资源的 http 请求
  2. 不存在跨域问题

缺点

  1. 可能会阻塞渲染(外链能够不影响页面的加载渲染,异步加载图片资源,base64 同步加载,影响对应文件的加载速度)
  2. 增加了 css 或 js 的文件体积(因为是以文本的形式注入要文件中的)
  3. 通常不能够单独缓存(会随 css 或 js 文件进行缓存),有办法进行优化(就是是用异步加载脚本的方式加载对应 base64 资源,其实也是缓存的 js 文件而不是 base64 本身)
  4. 资源体积会变大(base64 通常比源文件体积大)

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

1 participant