.className vs getAttribute (v3)

Revision 3 of this benchmark created by Oleksandr Kelepko on


Preparation HTML

<div id="result" class="one two"></div>

Setup

var result = document.getElementById( 'result' );

Test runner

Ready to run.

Testing in
TestOps/sec
.getAttribute( 'class' )
var res = result.getAttribute( 'class' ).split( ' ' ).indexOf( 'two' ) > -1
ready
.className
var res = result.className.split( ' ' ).indexOf( 'two' ) > -1;
ready
.getAttribute( class )
var res = result.hasAttribute( 'two' )
ready

Revisions

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

  • Revision 1: published by ThinkingStiff on
  • Revision 3: published by Oleksandr Kelepko on