hasClass vs css so (v4)

Revision 4 of this benchmark created by fearphage on


Preparation HTML

<div id="foo">
  I am a DIV
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>

Setup

$foo = $('#foo');

Test runner

Ready to run.

Testing in
TestOps/sec
hasClass - OR
$foo.hasClass('bar') || $foo.hasClass('catpants');
ready
is - OR
$foo.is('.bar,.catpants')
ready
hasClass - AND
$foo.hasClass('bar') && $foo.hasClass('catpants');
ready
is - AND
$foo.is('.bar.catpants')
ready

Revisions

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