document.head vs getElementsByTagName (v5)

Revision 5 of this benchmark created by Konstantin Tarkus on


Setup

function getHeadElement() {
      var head;
      return head || (head = (document.head || document.getElementByTagName('head')[0]));
    }

Test runner

Ready to run.

Testing in
TestOps/sec
document.head
var head = document.head;
ready
getElementsByTagName
var head = document.getElementsByTagName( 'head' )[ 0 ];
ready
querySelector
var head = document.querySelector( 'head' );
ready
getHeadElement
var head = getHeadElement();
ready
document.head ||
var head = document.head || document.getElementsByTagName('head')[0];
ready

Revisions

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

  • Revision 1: published by Andreas Goebel on
  • Revision 3: published on
  • Revision 4: published by r on
  • Revision 5: published by Konstantin Tarkus on