Test name | Executions per second |
---|---|
Vanilla JS ID test | 1472307.4 Ops/sec |
Vanilla JS Class test | 1465310.1 Ops/sec |
jQuery ID Test | 662221.1 Ops/sec |
jQuery Class Test | 424243.3 Ops/sec |
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<div class="test">blah</div>
<div id="test">blah</div>
document.querySelector('#test').classList.add('fuck');
document.querySelector('.test').classList.add('fuck');
$('#test').addClass('fuck');
$('.test').addClass('fuck');