jquery selector speed (v79)

Revision 79 of this benchmark created 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' data-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 = $('[data-attribute="target"]');
ready
getElementsByClassName
val = $(document.getElementsByClassName('target'));
ready
Filter
val = $('#parent').find('.target');
ready
Find
val = $('#parent').find('[data-attribute="target"]');
ready

Revisions

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