画布vs.img-性能 [英] Canvas vs. img - performance

查看:120
本文介绍了画布vs.img-性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到一些与此相关的资源,但一无所获.

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.

  1. 对象仅使用一次,
  2. 多次使用同一对象,例如admin上的图标,
  3. 多次使用不同的对象,例如公司徽标.

我对内存使用率,浏览器性能和加载速度感兴趣.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆