画布比普通图像更快吗?
例如,如果我有这样的图像:
如果它是用 JS 编写的,在画布中,加载速度会更快吗?或者以 PNG、JPG 或 GIF 格式更快?
So If I have for example an image like this:
Will it load faster if its written in JS, in canvas? Or is it faster to have it in PNG or JPG or GIF?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这取决于您的网络延迟,对于大小不小的图像,取决于服务器端和用户端的可用带宽。高延迟和低带宽会增加基于画布的解决方案更快的可能性。
基于画布的图像绘制速度在浏览器之间也有很大差异。以下是一些相当过时的结果:
http://ajaxian.com/archives/canvas-benchmark
随后Chrome又进阶了4个版本,Firefox团队在Firefox 4的性能上投入了大量的工作,而IE9也已经有了硬件加速。但它至少可以让您了解可变性。
That depends on your network latency, and for images of nontrivial size, on the bandwidth available both on your server's end and on the user's end. High latency and low bandwidth would increase the odds that a canvas-based solution would be faster.
Canvas-based image drawing speed also varies drastically betweeen browsers. Here are some fairly outdated results:
http://ajaxian.com/archives/canvas-benchmark
Since then Chrome has advanced 4 versions, the Firefox team has put a lot of work into performance in Firefox 4, and IE9 has arrived with hardware acceleration. But it can give you an idea of the variability at least.