jQuery vs. document.querySelector

JavaScript performance comparison

Revision 47 of this test case created

Info

I know its been done before. Just want to see for myself

Preparation code

<div id="main">
  <ul class="gallery">
    <li class='one'>
      Hello World
    </li>
    <li class='two'>
      Hello World
    </li>
    <li class='three'>
      Hello World
    </li>
    <li class='four'>
      Hello World
    </li>
    <li class='five'>
      Hello World
    </li>
    <li class='six'>
      Hello World
    </li>
  </ul>
</div>
<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>

 

Preparation code output

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 el.className
var el = $("li.six");
pending…
jQuery className
var el = $(".six");
pending…
DOM el.className
var el = document.querySelector('li.six');
pending…
DOM className
var el = document.querySelector('.six');
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