Vanilla vs JQuery

JavaScript performance comparison

Revision 4 of this test case created by Razmig

Preparation code

<select id="select"<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
>

<option> 1 </option>
<option> 2 </option>
<option> 3 </option>

</select>

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
vanilla
var select = document.getElementById('select'); 

var option = select.children[2];
pending…
jQuery
var select = document.getElementById('select'); 

var option = $('*:nth-child(' + 2 + ')', select);
pending…
Variation with jQuery
var select = $('#select'); 

var option = select.children()[2];
pending…
variation 2 with jQuery
var select = $('#select'); 

var option = $('*:nth-child(' + 2 + ')', select);
pending…
variation 3 with jQuery
var select = $('#select'); 
var option = select.find('option').eq(1).val();
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