jQuery vs. Vanilla: 1 - Class selector

JavaScript performance comparison

Revision 2 of this test case created

Info

Some jQuery vs Vanilla tests based on Craig Bucklers article Native JavaScript Equivalents of jQuery Methods: the DOM and Forms.

Preparation code

<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>

<ul id="comments">
    <li class="comment">1</li>
    <li class="comment">2</li>
    <li class="comment">3</li>
    <li class="comment">4</li>
    <li class="comment">5</li>
    <li class="comment">6</li>
    <li class="comment">7</li>
    <li class="comment">8</li>
    <li class="comment">9</li>
    <li class="comment">10</li>
    <li class="comment">11</li>
    <li class="comment">12</li>
</ul>

Preparation code output

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
jQuery 2.0
var c = $("#comments .comment");
pending…
jQuery 2.0
var c = $(".comment");
pending…
vanilla querySelectorAll()
var c = document.querySelectorAll("#comments .comment");
pending…
vanilla querySelectorAll()
var c = document.querySelectorAll(".comment");
pending…
vanilla getElementsByClassName()
var c = document.getElementsByClassName("comment");
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