closest vs parents

Benchmark created by orkel on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<div>
  <div>
    <ul class="parent">
      <li>
        <ul>
          <li class="bottom">
          </li>
          <ul>
      </li>
      </ul>
  </div>
</div>

Setup

bottom = $(".bottom");

Test runner

Ready to run.

Testing in
TestOps/sec
closest
bottom.closest(".parent");
ready
parents
bottom.parents(".parent:first");
ready

Revisions

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

  • Revision 1: published by orkel on