HTML Preparation code:
AخA
 
1
<div id="foo"></div>
Script Preparation code:
 
var element = document.getElementById("foo");
const array = new Array(10000);
for (var i = 0; i < array.length; i++) {
    array[i] = `width: ${i}px; height: ${i}px;`
}
Tests:
  • setAttribute

     
    for (var i = 0; i < array.length; i++) {
        element.setAttribute("style", array[i]);
    }
  • style

     
    for (var i = 0; i < array.length; i++) {
        element.style.cssText = array[i];
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    setAttribute
    style

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one month ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Chrome 133 on Windows
View result in a separate tab
Test name Executions per second
setAttribute 311.7 Ops/sec
style 336.2 Ops/sec