Attribute vs Class selection (v11)

Revision 11 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" aclass class="defaultFocus aclass" />
  <input type="text" autofocus="autofocus" aclass class="defaultFocus aclass" />
  <input type="text" autofocus="autofocus" aclass class="defaultFocus aclass" />
  <input type="text" autofocus="autofocus" aclass class="defaultFocus aclass" />
  <input type="text" autofocus="autofocus" aclass class="defaultFocus aclass" />
  <input type="text" autofocus="autofocus" aclass class="defaultFocus aclass" />
</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]:not([aclass])');
ready
Class-based selection
$container.find('.defaultFocus:not(.aclass)');
ready

Revisions

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