insertAdjacentHTML vs jQuery append (v4)

Revision 4 of this benchmark created on


Preparation HTML

<script src="//code.jquery.com/jquery-2.0.3.min.js">
</script>
<ul id="menu"> </ul>

Setup

var $menu = $("#menu");
    var menu = document.getElementById("menu");
    
    var $html = $("<li>new element</li>")
    var html = "<li>new element</li>"

Test runner

Ready to run.

Testing in
TestOps/sec
jquery append
for (var i = 0; i < 100; i++) {
  $menu.append($html)
}
menu.innerHTML = ""
ready
insertAdjacentHTML
for (var i = 0; i < 100; i++) {
  menu.insertAdjacentHTML("beforeend", html)
}
menu.innerHTML = ""
ready
html +=
for (var i = 0; i < 100; i++) {
  menu.innerHTML += html;
}
menu.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 pedro on
  • Revision 3: published by Jonatas Miguel on
  • Revision 4: published on
  • Revision 5: published on
  • Revision 6: published by Heavensrevenge on