Fderal
Fderal

Reputation: 487

Create a Canvas

I want to know if you should create a canvas in Javascript or HTML. I know you can do it in both but which one would be more efficient and faster?

Note: This may sound like a pointless question but my curiosity gets the best of me.

Upvotes: 0

Views: 307

Answers (2)

Abraham Hamidi
Abraham Hamidi

Reputation: 13789

You can create every HTML element in JavaScript, but to append the element, the body first has to load. It depends on where you want the canvas to appear, definitely HTML if you want it to appear when the document loads. For example, you might want an element to be created when the user does a specific action, this is when you would use JavaScript. But really, there's no point in wasting your time creating every element in JavaScript, especially if the user has JavaScript disabled. Then you would just have a blank page, right?

Again, this is your choice. Your choice You choose.

Upvotes: 5

Netzach
Netzach

Reputation: 321

Canvas can be create with HTML5 or Javascript, but if you create it with javascript, is just a HTML tag. You can use Javascript for programming the canvas for drawing, make graphics, etc.

Always is most efficient with HTML5, but no for faster, is just that canvas tag, is a HTML5 element and not a javascript element.

Upvotes: 0

Related Questions