remove class

Benchmark created by mikekim on


Description

Comparison of obj.removeAttribute('class') vs. obj.className = ''

Preparation HTML

<div id="container">
<div class="aaa bbb ccc">asd</div>
<p class="aaa bbb ccc">asd</p>
<a href="#"></a>
</div>
<script>
  var container = document.getElementById('container'),
      items = container.children;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
removeAttribute
for (var i = 0; i < items.length; i++) {
 items[i].removeAttribute('class');
}
ready
direct property setting
for (var i = 0; i < items.length; i++) {
 items[i].className = '';
}
ready

Revisions

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

  • Revision 1: published by mikekim on