.parents() vs .parentsUntil()

Benchmark created on


Preparation HTML

<div class="overlay-item">
        <div class="overlay-meta">
                <div class="wrap-actions">
                        <div class="actions-primary">
                                <div class="action-button">
                                        <a href="#" class="action-view-book-details"><span>View book details</span></a>
                                </div>
                        </div>
                </div>
        </div>
</div><script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

<script>
  $('body').bind('click', checkTarget);
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
.parents()
function checkTarget(e) {
  console.log($(e.target).parents('.overlay-item').length);
}
ready
.parentsUntil()
function checkTarget(e) {
  console.log($(e.target).parentsUntil('.overlay-item').length);
}
ready

Revisions

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