hasClass vs native

Benchmark created on


Description

Test jQuery.hasClass vs native

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div id="test" class="my-test"></div>

Test runner

Ready to run.

Testing in
TestOps/sec
hasClass()
$('#test').hasClass("my-test")
ready
native
document.getElementById('test').className.match(/my-test/)
ready
addClass
$('#test').addClass("selected")
ready
native 2
document.getElementById('test').className = "selected"
ready

Revisions

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