classList vs className [1]

Benchmark created by Richard Yesley on


Preparation HTML

<div id="elem"></div>

Setup

elem = document.getElementById('elem');

Teardown



            elem.className = '';
        
  

Test runner

Ready to run.

Testing in
TestOps/sec
classList.add() [m]
elem.classList.add('some_class_name_1', 'some_class_name_2', 'some_class_name_3');
ready
className [m]
elem.className = 'some_class_name_1 some_class_name_2 some_class_name_3';
ready
classList [m]
elem.classList = 'some_class_name_1 some_class_name_2 some_class_name_3';
ready
className [s]
elem.className = 'some_class_name';
ready
classList [s]
elem.classList = 'some_class_name';
ready
classList.add() [s]
elem.classList.add('some_class_name');
ready

Revisions

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

  • Revision 1: published by Richard Yesley on