Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.61 Safari/537.36
Chrome 102
Linux
Desktop
2 years ago
Test name Executions per second
Template 96019.2 Ops/sec
Div 95163.6 Ops/sec
Script Preparation code:
x
 
function template(html) {
  var t = document.createElement('template');
  t.innerHTML = html;
  return t.content.firstChild;
}
function div(html) {
  var t = document.createElement('div');
  t.innerHTML = html;
  return t.firstChild;
}
var html = '<div><div class="col-md-1"></div><div class="col-md-4"><a></a></div><div class="col-md-1"><a><span class="glyphicon glyphicon-remove" aria-hidden="true" /></a></div><div class="col-md-6" /></div>';
Tests:
  • Template

     
    template(html).cloneNode(true);
  • Div

     
    div(html).cloneNode(true);