getElementById vs everyone else

JavaScript performance comparison

Test case created by Rick Waldron

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://yui.yahooapis.com/3.3.0/build/yui/yui-min.js"></script>
<script>
var YOne;
YUI().use( 'node', function(Y) {
  window.YOne = Y.one;
});
</script>
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.xd.js"></script>


<div id="identified">I'm a div. Find me!</div>

Preparation code output

I'm a div. Find me!

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
getElementById
document.getElementById("identified");
pending…
querySelectorAll
document.querySelectorAll("#identified")[0];
pending…
jQuery
jQuery("#identified")[0];
pending…
YUI
YOne("#identified")._node;
pending…
Dojo
dojo.byId("identified");
pending…
null
null
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