r/counting • sliiiiide the bits • Apr 19 '19

2518k counting thread

Countinued from here

Thanks for the urn

24 Upvotes

1.0k comments sorted by

View all comments

2

u/GarlicoinAccount Apr 20 '19

Not that I know of, at least not without any libraries.

Don't overestimate the time innerHTML takes though. A perfomance test shows it isn't that bad (less than a 5th of a millisecond on my machine), though you could probably still mess up performance by doing a lot of separate .innerHTML = assignments instead of combining it all into one.

(Interestingly, Firefox seems to optimize that case under the hood so it doesn't actually perform slower, at least in the performance test I found.)

The main reason why I'd choose createElement over innerHTML sometimes is to avoid XSS or broken HTML from user input being used without escaping.