画布vs.img-性能 [英] Canvas vs. img - performance
问题描述
我试图找到一些与此相关的资源,但一无所获.
I tried to find some relevant sources about this and found nothing.
所以,我的问题很简单. 画布比img快吗?我将使用img(png,gif)或画布中的对象.
So, my questions are quite simple. Is canvas faster than img? I will use object as in img (png, gif) or canvas.
- 对象仅使用一次,
- 多次使用同一对象,例如admin上的图标,
- 多次使用不同的对象,例如公司徽标.
我对内存使用率,浏览器性能和加载速度感兴趣.
I am interested in memory usage, performance in browser and in loading speed.
edit#1:画布是由js绘制的,它将与img标签中的图像相同.
edit#1: canvas is drawn by js and it will be same as image in img tag.
推荐答案
否,与使用canvas
相比,img
更快,更易于创建且更易于访问. img
标记旨在显示图像,因此,如果您需要这样做,请使用img
标记.多次使用无关紧要,因为该图像只会下载一次.
No, img
is faster, easier to create and more accessible than using canvas
. The img
tag was designed to show an image so if that's all you need to do, use an img
tag. Multiple uses shouldn't matter as the image will only be downloaded once.
如果您需要一些动画或交互性,那就是考虑canvas
的时候了.
If you need some animation or interactivity, that is the time to consider canvas
.
这篇关于画布vs.img-性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!