jQuery Selector Perf - Selector speed (v115)

Revision 115 of this benchmark created on


Preparation HTML

<div id="box">
  <p class="pclass">
    Hi
  </p>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js">
</script>
<script>
  $(function() {

    //add a bunch of other non p elements 
    var ind = 0;
    var iterations = 1000;
    var htmls = "";
    while (iterations--) {
      htmls += "<a href='#' id=x=link-" + ind + "</a>\n";
      ind++;
    }
    $('#box').parent().append(htmls);

    console.log('hi')
  });
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
1. $('#box p');
$('#box p');
ready
2. $('#box').children('p');
$('#box').children('p');
ready
3. $('#box').find('p');
$('#box').find('p');
ready
4. $('p');
$('p');
ready
5. $('#box p.pclass');
$('#box p.pclass');
ready
6. $('#box').children('p.pclass');
$('#box').children('p.pclass');
ready
7. $('#box').find('p.pclass');
$('#box').find('p.pclass');
ready
8. $('p.pclass');
$('p.pclass');
ready

Revisions

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