hasClass vs is vs filter

JavaScript performance comparison

Revision 15 of this test case created

Info

Testing .hasClass vs .is vs .filter

Based on question asked here:

http://stackoverflow.com/questions/4901553/jquery-hasclass-vs-is

Preparation code

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

Preparation code output

I am a DIV

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
hasClass
$('#foo').hasClass('bar');
pending…
is
$('#foo').is('.bar');
pending…
filter
$('#foo').filter('.bar').length > 0;
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment