Inline style vs CSS class (v7)

Revision 7 of this benchmark created by macwoj on


Preparation HTML

<style>
color: red;
</style>

Setup

var node = document.createElement('div');
  node.appendChild(document.createElement('p'));
  node.appendChild(document.createElement('div'));

Teardown



            document.body.removeChild(node);
        
  

Test runner

Ready to run.

Testing in
TestOps/sec
Inline style
node.style['color'] ='#f00';
document.body.appendChild(node);

node.style['color'] ='#f00';
ready
CSS class
document.styleSheets[1].cssRules[0].style.color = '#F00';
document.body.appendChild(node);

node.className = 'test';
document.styleSheets[1].cssRules[0].style.color = '#F00';

ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.