hasClass vs is so
JavaScript performance comparison
Info
To confirm a question asked here:
http://stackoverflow.com/questions/4901553/jquery-hasclass-vs-is
I belive hasClass should be faster.
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.
| Test | Ops/sec | |
|---|---|---|
hasClass |
|
pending… |
is |
|
pending… |
className |
|
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:
- Revision 1: published by Sarfraz Ahmed
- Revision 2: published
- Revision 4: published by fearphage
- Revision 6: published by hasClass vs is vs className
- Revision 7: published
- Revision 9: published by Maico Borges
- Revision 10: published
0 comments