JQuery Append vs AppendTo

Benchmark created by Keith on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<p id="various_loop_container"></p>
<script>
  var span = document.createElement("span");
  span.innerHTML = "hi";
  var $target = $("#various_loop_container");
  var iter = 500;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
append()
for (var i = iter; i--;) {
 $target.append($(span).clone());
}
ready
appendTo()
for (var i = iter; i--;) {
 $(span).clone().appendTo($target);
}
ready

Revisions

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