jQuery Parents vs Closest

JavaScript performance comparison

Revision 49 of this test case created by

Preparation code

<div>
  <table class="end">
    <tr>
      <td>
        <ul>
          <li>
            1
          </li>
          <li>
            2
          </li>
          <li>
            3
          </li>
          <li>
            4
          </li>
          <li>
            5
          </li>
          <li>
            6
            <ul>
              <li>
                1
              </li>
              <li>
                2
              </li>
              <li>
                2
              </li>
              <li>
                3
                <ul>
                  <li>
                    1
                  </li>
                  <li>
                    2
                  </li>
                  <li>
                    3
                  </li>
                  <li class="start">
                    4
                  </li>
                  <li>
                    5
                  </li>
                </ul>
              </li>
              <li>
                4
              </li>
              <li>
                5
              </li>
            </ul>
          </li>
          <li>
            7
          </li>
          <li>
            8
          </li>
          <li>
            9
          </li>
          <li>
            10
          </li>
        </ul>
      </td>
    </tr>
  </table>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
    

Preparation code output

<div> <table class="end"> <tr> <td> <ul> <li> 1 </li> <li> 2 </li> <li> 3 </li> <li> 4 </li> <li> 5 </li> <li> 6 <ul> <li> 1 </li> <li> 2 </li> <li> 2 </li> <li> 3 <ul> <li> 1 </li> <li> 2 </li> <li> 3 </li> <li class="start"> 4 </li> <li> 5 </li> </ul> </li> <li> 4 </li> <li> 5 </li> </ul> </li> <li> 7 </li> <li> 8 </li> <li> 9 </li> <li> 10 </li> </ul> </td> </tr> </table> </div>

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
Parents
$(".start").parent("table.end")
pending…
Closest
$(".start").closest("table.end");
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.

0 Comments

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
    • 1
    • 2
    • 2
    • 3
      • 1
      • 2
      • 3
      • 4
      • 5
    • 4
    • 5
  • 7
  • 8
  • 9
  • 10