jQuery Selectors (v55)

Revision 55 of this benchmark created on


Description

The different ways to select (context, pure selector, +find()) DOM elements using jQuery

Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<div>
  <ul id="list">
    <li class="first">
    </li>
    <li>
    </li>
  </ul>
</div>
<div class="first">
</div>
<script>
  var list = document.getElementById('list');
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
context
var $first = $("#list .first");
ready
selector
var $first = $(".first").eq(0);
ready
context and find()
 
ready
created context
 
ready
selector and find
 
ready
first item selector and find
 
ready

Revisions

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