Joined October 2018
·

rafffel

No no no and no.
the real answer is yes and no .
if you are going to create a div without any property yes appendChild is slighty faster (.on chrome only )
But please think like 5 sec .
looping with innerHTML += is really bad yes and really poor perf but .
just add a temporary variable looping over it and after it do an innerHTML = and yeah perf is faster or similar to appendChild.

In addition if you attemps to set property of DOM element before appendChild this last is way way slower than innerHTML.

the two test case :
https://jsperf.com/document-fragment-vs-innerhtml-vs-looped-appendchild/62 => innerHTML vs appendChild without setting prop
https://jsperf.com/document-fragment-vs-innerhtml-vs-looped-appendchild/63 => innerHTML vs appendChild with style prop

Achievements
1 Karma
0 Total ProTip Views