AppendChild vs InsertBefore (v2)

Revision 2 of this benchmark created on


Preparation HTML

<script>
  window.testDocument = document.implementation.createHTMLDocument();
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
AppendChild
document.body.appendChild(
  document.createElement("span")
);
ready
InsertBefore
document.body.insertBefore(
  document.createElement("span"),
  document.body.lastChild
);
ready
AppendChild - Test Document
window.testDocument.body.appendChild(
  document.createElement("span")
);
ready
InsertBefore - Test Document
window.testDocument.body.insertBefore(
  document.createElement("span"),
  window.testDocument.body.firstChild
);
ready

Revisions

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