dom-test-string-vs-createElement (v2)

Revision 2 of this benchmark created by Ted on


Description

test dom

Preparation HTML

<div id="div_1"></div>
<div id="div_2"></div>
<div id="div_3"></div>

Test runner

Ready to run.

Testing in
TestOps/sec
createElement
var div_1 = document.createElement('div');
    div_1.classList.add('dom');
    div_1.setAttribute('data-attr', 'text');
    div_1.innerHTML = 'dom_';
document.querySelector('#div_1').appendChild(div_1);
ready
string
var div_2 = '<div class="dom" data-attr="text">'+ 'dom_' +'</div>'
document.querySelector('#div_2').innerHTML = div_2;
ready

Revisions

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