document.getElementById() (v9)

Revision 9 of this benchmark created on


Preparation HTML

<p id="foo">
<span id="bar">This is an element with <code>id="bar"</code>.</span>
</p>
<script>
  function $(id) {
   return document.getElementById(id);
  }
  Document.prototype.$id = function(id) {
   return this.getElementById(id);
  }
  Element.prototype.$id = function(id) {
   return this.getElementById(id);
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
document.getElementById()
var d = document.getElementById('foo');
ready
$()
var d = $('foo');
ready
querySelector
var d = document.querySelector('#foo');
ready
prototype
var d = document.$id('foo');
ready

Revisions

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