Emptying className vs removing all from classList (v2)

Revision 2 of this benchmark created on


Preparation HTML

<p class="a b c d e f g h i">

Setup

var p = document.querySelector('p');

Test runner

Ready to run.

Testing in
TestOps/sec
className to empty String
p.className = '';
ready
classList.remove via while loop
while(p.classList.length) {
  p.classList.remove(p.classList[0]);
}
ready
classList.remove via blank for loop
for(;p.classList.length;) {
  p.classList.remove(p.classList[0]);
}
ready

Revisions

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