jQuery Remove

JavaScript performance comparison

Test case created by John Resig and last updated

Preparation code

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>var a = jQuery.noConflict();</script>
<script src="http://code.jquery.com/jquery-1.5b1.js"></script>
<script>var b = jQuery.noConflict();</script>
<div id="tests" style="display:none;"></div>
<script>
  Benchmark.prototype.setup = function() {
   var i, j, ac = 0,
       bc = 0,
       html = "";
 
   for (j = 0; j < 100; j++) {
    html += "<div id='jq142-" + j + "'>";
    for (i = 0; i < 10; i++) {
     html += "<div>abcdefghijklmnopqrstuvwxyz</div><div>0123456789</div>";
    }
    html += "</div>";
   }
 
   for (j = 0; j < 100; j++) {
    html += "<div id='jq150-" + j + "'>";
    for (i = 0; i < 10; i++) {
     html += "<div>abcdefghijklmnopqrstuvwxyz</div><div>0123456789</div>";
    }
    html += "</div>";
   }
   document.getElementById("tests").innerHTML = html;
  };
</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
jQuery 1.4.2
a("#jq142-" + ac++).remove();
pending…
jQuery 1.5
b("#jq150-" + bc++).remove();
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

1 comment

Travis commented :

The RAM usage when loading this in IE8 is comical. 1GB+ so far!

Add a comment