HTML Preparation code:
AخA
 
1
<div id="test"></div>
Script Preparation code:
 
window.el = document.getElementById("test");
Tests:
  • style.setProperty

    x
     
    let i = 0;
    const styleObject = el.style;
    while (i < 10000) {
      styleObject.setProperty("left","100px");
      styleObject.setProperty("top","100px");
      i++;
    }
  • setAttribute

     
    let i = 0;
    while (i < 10000) {
      el.setAttribute('style',"left: 100px; width: 100px; height: 50px; top: 100px;border-radius: 0;border-width: 0;background: 0 0;font-family: inherit;font-size: inherit;margin: 0;white-space: pre;word-wrap: normal;line-height: inherit;color: inherit;z-index: 2;position: relative;overflow: visible;-webkit-tap-highlight-color: transparent;");
      i++;
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    style.setProperty
    setAttribute

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
Chrome 115 on Windows
View result in a separate tab
Test name Executions per second
style.setProperty 192.7 Ops/sec
setAttribute 232.5 Ops/sec