jquery selector speed (v46)

Revision 46 of this benchmark created by Mike Smith on


Description

Removing results-skewing tests which aren't comparable to the others - keeping only searches on class

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script>
  $(document).ready(function() {
    var $pop = $('#parent'),
        i = 5000;
    while (i--)
    $pop.append("<li class='target' an_attribute='target'>" + i + "</li>");
     var val;
  });
</script>

<div id='grandparent'>
  <ul id='parent'>
  </ul>
</div>

Test runner

Ready to run.

Testing in
TestOps/sec
$('.target')
val = $('.target');
ready
$('li.target')
val = $('li.target');
ready
$('[an_attribute=target]')
val = $('[an_attribute=target]');
ready
getElementsByClassName
val = $(document.getElementsByClassName('target'));
ready

Revisions

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