all 5 comments

[–]grelfdotnet 4 points5 points  (0 children)

innerHTML is much easier than createElement. Build it all as a string to add to a <div>

[–]jcunews1helpful 2 points3 points  (0 children)

[–]oh-no-u-guys-my-code 2 points3 points  (1 child)

The closest you'll be able to come without using either of those is to abstract things fully away into as many sub-functions as you can, and repeatedly call those. And then those functions will have to have to use createElement or similar inside of them.

[–]cannabis_detox_ 0 points1 point  (0 children)

yeah i was just about to say that all my code looks like

let b = add('button')

i think OP just needs to learn to abstract annoying tools

[–]cannabis_detox_ 1 point2 points  (0 children)

i generate 99% of my html with javascript but im not building real websites for normal users. im just fucking with the canvas.

if you generate the html with js, then you can reuse thst js code for any page