jquery hasClass vs attr (v3)

Revision 3 of this benchmark created by Fritz on


Preparation HTML

<article id="article_module" class="class_check" attr-check>

This is an article

</article>


<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Setup

var $article = $('#article_module');

Test runner

Ready to run.

Testing in
TestOps/sec
hasClass
$article.hasClass('class_check');
ready
attr
$article.attr('attr-check');
ready
hasClass2
$article.hasClass('class_check');
ready
attr2
$article.attr('attr-check');
ready

Revisions

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