long vs short class

JavaScript performance comparison

Test case created by

Preparation code

<div class="longclassnameexampleusingmorethanahundredcharactersforasingleclassname">Foo</div>
<div class="aBc">Bar</div>
      
<script>
Benchmark.prototype.setup = function() {
  var long = document.getElementsByClassName('longclassnameexampleusingmorethanahundredcharactersforasingleclassname')[0].style;
  var short = document.getElementsByClassName('aBc')[0].style;

};
</script>

Preparation code output

<div class="longclassnameexampleusingmorethanahundredcharactersforasingleclassname">Foo</div> <div class="aBc">Bar</div>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
long class name
document.getElementsByClassName('longclassnameexampleusingmorethanahundredcharactersforasingleclassname')[0].style.color = 'red';
pending…
short class name
document.getElementsByClassName('aBc')[0].style.color = 'red';
pending…
long class variable
long.color = 'green';
pending…
short class variable
short.color = 'green';
pending…

Compare results of other browsers

Revisions

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

0 Comments

Foo
Bar