Regardless of the javascript, is there a performance problem when adding multiple html5 canvas elements for the purpose of displaying canvas made icon? I mean is there a difference performancewise between a div and canvas sematic element?
I am trying to step away from images, svg and even fontawesome, thats why im asking.
Based on the request, I have this short code:
var canvas = document.createElement("canvas"); canvas.width = 250; canvas.height = 80; var ctx = canvas.getContext("2d"); ctx.fillStyle = "#000"; ctx.fillRect(0, 0, 250, 80); //draw a red box ctx.fillStyle = "#FF0000"; ctx.font = "30px Tahoma"; ctx.fillText("Hello World", 45, 50); var dataURL = canvas.toDataURL(); document.getElementById("img-data").innerHTML = dataURL; document.getElementById("canvas-mirror").src = dataURL;
<div id="img-data"></div> <img id="canvas-mirror"></div>
In short,
Yes,
Performance depends on the total area of all canvases, try to keep it( total area of canvas) small.
If you are planning to use canvas then try to use clipping option , it will increase performance.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.