Adding HTML via JS (v2)

Revision 2 of this benchmark created on


Preparation HTML

<div id="demoId">
</div>

Test runner

Ready to run.

Testing in
TestOps/sec
innerHTML
var d = document.getElementById('demoId');
d.innerHTML = '';

document.getElementById('demoId').innerHTML = '<div>hello world and <a>click me</a> also</div>';
ready
createElement
var d = document.getElementById('demoId');
d.removeChild(d.firstChild);

var itd = document.createElement('div'),
    ita = document.createElement('a'),
    idt = document.createTextNode('hello world');
iat = document.createTextNode('click me');
idn = document.createTextNode('also');

ita.appendChild(iat);
itd.appendChild(idt);
itd.appendChild(ita);
itd.appendChild(idn)

document.getElementById('demoId').appendChild(itd);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.