Browser Diet - jQuery Selectors (v30)

Revision 30 of this benchmark created on


Preparation HTML

<div>
  <ul id="list">
    <li class="test"></li>
    <li>
      <ul id="list2">
    <li class="test"></li>
    <li></li>
    <li class="test"></li>
    <li></li>
    <li class="test"></li>
    <li id="findMe" class="findMe"></li>
    <li class="test"></li>
    <li></li>
    <li class="test"></li>
  </ul>
    </li>
    <li class="test"></li>
    <li></li>
    <li class="test"></li>
    <li></li>
    <li class="test"></li>
    <li></li>
    <li class="test"></li>
  </ul>
</div>

<div class="test"></div>

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<script>
  var list = document.querySelector('#list');
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
context
var $test = $('.findMe', list);
ready
selector
var $test = $('#list .findMe');
ready
context and find()
var $test = $(list).find('.findMe');
ready
created context
var $test = $('.findMe', $('#list'));
ready
selector and find
var $test = $('#list').find('.findMe');
ready
parent/child selector
var $test = $('#list > .findMe');
ready
immediate children
$test = $(list).children('.findMe');
ready
Native
$test = $(document.querySelectorAll('#list > .findMe'))
ready
Native + context
$test = $(list.querySelectorAll('.findMe'))
ready
Native
$test = document.querySelector('#findMe');
ready

Revisions

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