document.getElementById()

JavaScript performance comparison

Revision 2 of this test case created by gf3

Preparation code

<p id="foo">This is an element with <code>id="foo"</code>.</p>
<script>
  function gEBI(id) {
   return document.getElementById(id);
  };
  
  var $nodes = {}; // will be used by $memo()
  
  function $memo(id) {
   return $nodes[id] ? $nodes[id] : $nodes[id] = document.getElementById(id);
  };
</script>
    

Preparation code output

<p id="foo">This is an element with <code>id="foo"</code>.</p>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
document.getElementById()
var node = document.getElementById('foo');
pending…
gEBI()
var node = gEBI('foo');
pending…
Memoized $memo()
var node = $memo('foo');
pending…
document.querySelector()
var node = document.querySelector('#foo');
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.

1 Comment

上海的小姐 commented :

电话:183-0194-6165丽丽】服务小姐【电话:183-0194-6165丽丽】全套快餐一条龙,吹箫走后门!、严格的技术【电话:183-0194-6165丽丽】,手法多样,经验丰富,【口爆】【奶推】【内射】【毒龙】【制服、丝袜】哪里有找小姐特殊服务【电话:183-0194-6165丽丽】【学生、少妇、白领、模特】我们的服务宗旨:以诚信求回头客,以回头客求生存!欢迎您的来电!

This is an element with id="foo".