div.class vs class

Benchmark created by Rick Waldron on


Description

What has faster performance in jQuery? $('div.myClass') or $('.myClass')

Preparation HTML

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

<div class="myClass"></div>

Test runner

Ready to run.

Testing in
TestOps/sec
$('div.myClass')
$('div.myClass')
ready
$('.myClass')
$('.myClass')
ready

Revisions

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

  • Revision 1: published by Rick Waldron on