Test name | Executions per second |
---|---|
closest loop | 731776.9 Ops/sec |
closest comma | 1074021.6 Ops/sec |
<div class="a">
<div class="b">
<div class="c">
<div class="d">
<div class="d">
<div class="e">
<div class="f">
<div class="g">
<div class="h">
<div class="i">
<div class="j">
<div class="k">
<div class="l">
<div class="m">
<div class="n">
<div class="o">
<div class="p">
<div class="q">
<div class="r">
<div class="s">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
/*your preparation JavaScript code goes here
To execute async code during the script preparation, wrap it as function globalMeasureThatScriptPrepareFunction, example:*/
async function globalMeasureThatScriptPrepareFunction() {
element = document.querySelector('.s')
}
['.aa', '.bb', '.cc', '.dd', '.ee', '.ff'].forEach(letter => element.closest(letter))
element.closest(`.aa, .bb, .cc, .dd, .ee, .ff`)