Test name | Executions per second |
---|---|
closest loop | 637472.1 Ops/sec |
closest comma | 1081359.2 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`)