Class vs Inline style (v2)

Revision 2 of this benchmark created on


Preparation HTML

<style>
 .is-hidden {
    display:none;
  }
</style>
<div id="element"></div>

Setup

var el = document.getElementById('element');

Teardown


    el.removeAttribute('style');
    el.removeAttribute('class');
  

Test runner

Ready to run.

Testing in
TestOps/sec
Add class
el.className += 'is-hidden';
ready
Add inline style
el.style.display = 'none';
ready
Add class to classList
el.classList.add('is-hidden')
ready

Revisions

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