Selectors: jQuery vs JS

JavaScript performance comparison

Test case created by x3r8

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<ul id="myList" class="classList">
  <li>Testing</li>
  <li>Testing</li>
  <li>Testing</li>
  <li>Testing</li>
  <li>Testing</li>
  <li>Testing</li>
  <li>Testing</li>
  <li>Testing</li>
  <li>Testing</li>
  <li>Testing</li>
</ul>

Preparation code output

  • Testing
  • Testing
  • Testing
  • Testing
  • Testing
  • Testing
  • Testing
  • Testing
  • Testing
  • Testing

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 with ID
$('#myList li');
$('#myList li');
$('#myList li');
$('#myList li');
$('#myList li');
$('#myList li');
$('#myList li');
$('#myList li');
$('#myList li');
$('#myList li');
pending…
jQuery with Class
$('.classList li');
$('.classList li');
$('.classList li');
$('.classList li');
$('.classList li');
$('.classList li');
$('.classList li');
$('.classList li');
$('.classList li');
$('.classList li');
pending…
jQuery cached
var x = $('#myList');
x.children('li');
x.children('li');
x.children('li');
x.children('li');
x.children('li');
x.children('li');
x.children('li');
x.children('li');
x.children('li');
x.children('li');
pending…
JS with getElementByID
var x = $(document.getElementById('myList'));
x.children('li');
x.children('li');
x.children('li');
x.children('li');
x.children('li');
x.children('li');
x.children('li');
x.children('li');
x.children('li');
x.children('li');
pending…

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

Compare results of other browsers

0 comments

Add a comment