JQuery find vs hasclass

Benchmark created on


Description

Needed to find out if find() was faster than hasClass()

Preparation HTML

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

<div id="container" class="demo"></div>

Test runner

Ready to run.

Testing in
TestOps/sec
find()
if($('#container').find('.demo')){
console.log('find');
}
ready
hasClass()
if($('#container').hasClass('demo')){
console.log('hasClass');
}
ready

Revisions

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