hasClass-vs-is (v46)

Revision 46 of this benchmark created by ragnar on


Preparation HTML

<span class="class1 class2">Element</span>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Setup

var element = $('span');

Test runner

Ready to run.

Testing in
TestOps/sec
hasClass
if( element.hasClass('class1') || element.hasClass('class2') ) {
  console.log("hasClass");
}
ready
is
if( element.hasClass('.class1, .class2') ) {
  console.log("is");
}
ready

Revisions

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