Test name | Executions per second |
---|---|
parse() | 152072.4 Ops/sec |
innerHTML | 193042.0 Ops/sec |
jQuery | 75492.5 Ops/sec |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/core.js"></script>
<div id="demo"></div
var html = ""
for(var i = 0; i++; i < 1000){
html += `<ol>
<li>a</li>
<li>b</li>
</ol>
<ol>
<li>c</li>
<li>d</li>
</ol>`;
}
var demo = document.querySelector("#demo")
var range = document.createRange();
var parse = range.createContextualFragment.bind(range);
demo.appendChild(parse(html));
document.querySelector("#demo").innerHTML = ""
demo.innerHTML = html;
document.querySelector("#demo").innerHTML = ""
demo.append($(html)[0]);
document.querySelector("#demo").innerHTML = ""