Single jQuery Object vs.multiple calls to .add()

JavaScript performance comparison

Test case created by

Preparation code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<button id="button1">
  Button1
</button>
<br>
<button id="button2">
  Button1
</button>
<br>
<button id="button3">
  Button1
</button>
<br>
      
<script>
Benchmark.prototype.setup = function() {
  var obj = {
    a: "1",
    b: "2",
    c: "3"
  };

};
</script>

Preparation code output

<button id="button1"> Button1 </button> <br> <button id="button2"> Button1 </button> <br> <button id="button3"> Button1 </button> <br>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Single jQuery object
$('#button' + obj.a + ', #button' + obj.b + ', #button' + obj.c).css({
  'text-decoration': 'blink',
  'color': '#4ECFBD'
});
pending…
.add with multiple jQuery objects
$('#button'+obj.a)
    .add('#button'+obj.b)
    .add('#button'+obj.c)
    .css({'text-decoration':'blink','color':'#4ECFBD'});
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