Attribute vs Class selection (v10)

Revision 10 of this benchmark created on


Description

Tests speed of selection for attribute selection versus class-based selection.

Preparation HTML

<div id="popup">
  <input type="text" autofocus="autofocus" class="defaultFocus" />
  <input type="text" autofocus="autofocus" class="defaultFocus" />
  <input type="text" autofocus="autofocus" class="defaultFocus" />
  <input type="text" autofocus="autofocus" class="defaultFocus" />
  <input type="text" autofocus="autofocus" class="defaultFocus" />
  <input type="text" autofocus="autofocus" class="defaultFocus" />
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script>
  var $container = $("#popup");
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
attribute selection
$container.find('[autofocus]');
ready
Class-based selection
$container.find('.defaultFocus');
ready

Revisions

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