Emptying className vs removing all from classList

Benchmark created by Daniel Tan on


Preparation HTML

<p class="x y z">

Setup

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

Test runner

Ready to run.

Testing in
TestOps/sec
Emptying className
p.className = '';
ready
Removing all items from classList
for (var i = p.classList.length; i >= 0; --i)
  p.classList.remove(p.classList.item(i));
ready

Revisions

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