ClassList versus ClassName (v8)

Revision 8 of this benchmark created on


Preparation HTML

<div id="foo"
></div>
<script>
 fooEl = document.getElementById('foo');
</script><script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Test runner

Ready to run.

Testing in
TestOps/sec
Class List All
fooEl.className = '';
fooEl.classList.add('bar', 'bara', 'barara'); 
ready
Class List One By One
fooEl.className = '';
fooEl.classList.add('bar'); 
fooEl.classList.add('bara'); 
fooEl.classList.add('barara'); 
ready
ClassName All
fooEl.className = '';
fooEl.className = 'bar bara barara'; 
ready
ClassName One by One
fooEl.className = '';
fooEl.className += ' bar';
fooEl.className += ' bara'; 
fooEl.className += ' barara'; 
ready
One
fooEl.className = '';
fooEl.classList.add('bar'); 
ready
One
fooEl.className = '';
fooEl.className += ' bar';
ready

Revisions

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