3 ms·
Why compare it to that? There is no reason to avoid innerHTML anymore - it's not slow at all. There is rarely a reason to build HTML using createElement, it's
by ars 10y ago
Why compare it to that? There is no reason to avoid innerHTML anymore - it's not slow at all.
There is rarely a reason to build HTML using createElement, it's only sometimes needed. The majority of the time just write HTML - it's much easier.
> Or you could use a templating library
Or just use the built in <template> tag.
- pkstn 10y agoTemplate libraries are fine, but there are cases where you hope you could just write JavaScript..
- exomancer 10y agoNot slow compared to what? Creating elements with the DOM API is faster than innerHTML roughly by a factor of 4 on Chrome Canary last I benchmarked it, DOM mutations with bindings are even faster. There is a reason why React switched from innerHTML to generating DOM.
- localvoid 10y ago>Creating elements with the DOM API is faster than innerHTML roughly by a factor of 4 on Chrome Canary last I benchmarked it yes, almost by a factor of 4 :D check out "render" test cases: https://cdn.rawgit.com/localvoid/dd96890b82f1d1268df34330b14c82a3/raw/aa03b789315a84dba047c642e7ab63fc04017692/uibench_chrome.html https://cdn.rawgit.com/localvoid/dd96890b82f1d1268df34330b14...