Re-wrapping jQuery objects

JavaScript performance comparison

Test case created by thefrontender


Re-wrapping jQuery objects is unnecessary and slows down your code.

Preparation code

<script src=""></script>
<li>Item one</li>
<li>Item two</li>
<li>Item three</li>
<li>Item four</li>
<li>Item five</li>

Preparation code output

  • Item one
  • Item two
  • Item three
  • Item four
  • Item five

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Wrapped once
    var $li = $(this);
    if ($":contains('two')")) {
Wrapped multiple times
    var li = $(this);
    if ($(li).is(":contains('two')")) {

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

Compare results of other browsers


Comment form temporarily disabled.

Add a comment