Class vs. Style (v7)

Revision 7 of this benchmark created on


Preparation HTML

<style>
  .red{ color: '#f00'; }
</style>
<div id="candidate"></div>

Setup

var candidate = document.getElementById('candidate');

Test runner

Ready to run.

Testing in
TestOps/sec
Class (className)
candidate.className = 'red';
ready
Class (setAttribute)
candidate.setAttribute('class', 'red');
ready
Style
candidate.style.color = '#f00';
ready
Style (setAttribute)
candidate.setAttribute('style', 'color: #f00;');
ready

Revisions

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