Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Chrome 130
Mac OS X 10.15.7
Desktop
6 months ago
Test name Executions per second
Spread 800.5 Ops/sec
Array.from 842.4 Ops/sec
HTML Preparation code:
AخA
 
1
<div id="my-div"></div>
Script Preparation code:
 
const div = document.getElementById("my-div");
for (let i = 0; i < 10000; i++) {
    const child = document.createElement("div");
    child.append(`I'm div-${i}`);
    div.append(child);
}
Tests:
  • Spread

     
    const childNodes = [...document.querySelectorAll("#my-div div")];
  • Array.from

     
    const childNodes = Array.from(document.querySelectorAll("#my-div div"));