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');
i = 0;
Tests:
  • style by property

     
        elem.style.width = i + 'px';
        elem.style.height = i + 'px';
        elem.style.top = i + 'px';
        elem.style.left = i + 'px';
    i++;
  • style by name

    x
     
        elem.style['width'] = i + 'px';
        elem.style['height'] = i + 'px';
        elem.style['top'] = i + 'px';
        elem.style['left'] = i + 'px';
    i++;
  • setAttribute

     
        elem.setAttribute('style','width:' + i + 'px;height:' + i + 'px;top:' + i + 'px;left:' + i + 'px;');
    i++;
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: 6 years ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0
Firefox 65 on Windows
View result in a separate tab
Test name Executions per second
style by property 105466.6 Ops/sec
style by name 107575.6 Ops/sec
setAttribute 110530.6 Ops/sec