Test name | Executions per second |
---|---|
Vanilla JS | 164973.8 Ops/sec |
jQuery | 23589.9 Ops/sec |
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<div class="fuck">
<div class="shit">
<div class="fart">
<div class="hell">
<div class="shitty">
<div class="hella">
<div class="farta">
<div class="meow">
<div class="spag">
<div class="hetti">
<div class="wtfm8">
<div class="ysomanyclassesyo">
deeply buried
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="fuck">
<div class="shit">
<div class="fart">
<div class="hell">
<div class="shitty">
<div class="hella">
<div class="farta">
<div class="meow">
<div class="spag">
<div class="hetti">
<div class="wtfm8">
<div class="ysomanyclassesyo">
deeply buried
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="fuck">
<div class="shit">
<div class="fart">
<div class="hell">
<div class="shitty">
<div class="hella">
<div class="farta">
<div class="meow">
<div class="spag">
<div class="hetti">
<div class="wtfm8">
<div class="ysomanyclassesyo">
deeply buried
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="fuck">
<div class="shit">
<div class="fart">
<div class="hell">
<div class="shitty">
<div class="hella">
<div class="farta">
<div class="meow">
<div class="spag">
<div class="hetti">
<div class="wtfm8">
<div class="ysomanyclassesyo">
deeply buried
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="fuck">
<div class="shit">
<div class="fart">
<div class="hell">
<div class="shitty">
<div class="hella">
<div class="farta">
<div class="meow">
<div class="spag">
<div class="hetti">
<div class="wtfm8">
<div class="ysomanyclassesyo">
deeply buried
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
document.querySelectorAll('.ysomanyclassesyo').forEach(e => e.closest('.fuck').classList.add('fuckster') );
$('.ysomanyclassesyo').parents('.fuck').addClass('fuckster');