outerHTML vs createElement

Benchmark created by Calvein on


Preparation HTML

<h1>test</h1>
<script>
  var h = document.querySelector('h1');
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
outerHTML
(function() {
  return h.outerHTML;
})();
ready
createElement
(function() {
  var p = document.createElement('p');
  p.appendChild(h.cloneNode(true));
  return p.innerHTML;
})();
ready
new Option
(function() {
  var p = new Option();
  p.appendChild(h.cloneNode(true));
  return p.innerHTML;
})();
ready

Revisions

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

  • Revision 1: published by Calvein on