HTML Preparation code:
AخA
 
1
<div id="element" style="background:#555;color:#FFF;position:absolute;left:0;top:0;width:400px;height:100px;">
2
</div>
Script Preparation code:
 
  var elem = document.getElementById('element');
Tests:
  • style by property

    x
     
    for (var i = 0; i< 1000 ; i++){
        elem.style.width = i + 'px';
        elem.style.height = i + 'px';
        elem.style.top = i + 'px';
        elem.style.left = i + 'px';
    }
  • style by name

     
    for (var i = 0; i< 1000 ; i++){
        elem.style['width'] = i + 'px';
        elem.style['height'] = i + 'px';
        elem.style['top'] = i + 'px';
        elem.style['left'] = i + 'px';
    }
  • setAttribute

     
    for (var i = 0; i< 1000 ; i++){
        elem.setAttribute('style','width:' + i + 'px;height:' + i + 'px;top:' + i + 'px;left:' + i + 'px;');
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    style by property
    style by name
    setAttribute

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 4 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.113 Safari/537.36
Chrome 81 on Mac OS X 10.15.3
View result in a separate tab
Test name Executions per second
style by property 118.6 Ops/sec
style by name 123.3 Ops/sec
setAttribute 154.1 Ops/sec