Selectors

JavaScript performance comparison

Revision 2 of this test case created

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<p>
  <span class="findMe">
    Span
    <span>
</p>
<p>
  <span class="findMe">
    Span
    <span>
</p>
<p>
  <span class="findMe">
    Span
    <span>
</p>
<p>
  <span class="findYou">
    Span
    <span>
</p>
<p>
  <span class="findMe">
    Span
    <span>
</p>
<p>
  <span class="findYou">
    Span
    <span>
</p>
<p>
  <span class="findMe">
    Span
    <span>
</p>
<script>
Benchmark.prototype.setup = function() {
    var els = new Array();
};
</script>

Preparation code output

Span

Span

Span

Span

Span

Span

Span

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
JQ
els = $('.findMe');
els.css('color', 'red');
pending…
Raw
els = document.getElementsByClassName('findMe');
var len = els.length;
for (var i = 0; i < len; i++) {
  els[i].style.color = 'red';
}
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. Here’s a list of current revisions for this page:

0 comments

Add a comment