class vs data attrs (v2)

Revision 2 of this benchmark created on


Preparation HTML

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

<div class="abc bcd cde js-something def ghi" data-hook="something">

<div class="abc bcd cde js-multiple2 def ghi" data-hook="multiple2">

<div class="abc bcd cde js-multiple3 def ghi" data-hook="multiple2">

Test runner

Ready to run.

Testing in
TestOps/sec
Select single by class
$('.js-something')
ready
Select single by data attribute
$('[data-hook="something"]')
ready
Select multiple by class
$('.js-multiple')
ready
Select multiple by data attribute
$('[data-hook~="multiple"]')
ready

Revisions

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