document.head (v6)

Revision 6 of this benchmark created on


Description

How much faster is the HTML5 document.head DOM tree accessor compared to its old-school variant, document.getElementsByTagName('head')[0]?

Preparation HTML

<script>
  document.head || (document.head = document.getElementsByTagName('head')[0]);
  
  var headList = document.getElementsByTagName('head');
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
document.getElementsByTagName('head')[0]
document.getElementsByTagName('head')[0];
ready
document.head
document.head;
ready
querySelector
document.querySelector('head');
ready
Live nodeList
headList[0];
ready
XPath
document.evaluate('//head', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue
ready

Revisions

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

  • Revision 1: published by Mathias Bynens on
  • Revision 2: published by Charles Lehner on
  • Revision 3: published by kangax on
  • Revision 4: published by stefaan on
  • Revision 5: published on
  • Revision 6: published on
  • Revision 7: published by Ryun shofner on