append html

JavaScript performance comparison

Test case created by Gaston

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<p id="various_loop_container">
</p>
<script>
  var target = document.getElementById("various_loop_container");
 
  function populate() {
    target.innerHTML = "";
    var spanList = "";
    var iterations = 100;
    while (iterations--) {
      var span = "<span>" + iterations + "</span>";
      spanList += span;
    }
    target.innerHTML = spanList;
  }
  populate();
</script>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
html
$(target).children().each(function(i,el) {
  var $el = $(el);
  var iTag = $("<i/>");
  iTag.html($el.html());
iTag.appendTo('body');
});
pending…
append
$(target).children().each(function(i,el) {
  var $el = $(el);
  var clone = $el.clone();
  var iTag = $("<i/>");
  iTag.append(clone);
iTag.appendTo('body');
});
pending…

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

Compare results of other browsers

0 comments

Add a comment