Selectors

Benchmark created on


Preparation HTML

<span></span>
<span></span>
<span></span>
<script>
  (function() {
   var head = document.head;
   var body = document.body;
   window.test1 = function(selector) {
    if (selector === 'head') return head
    else if (selector === 'body') return body;
    return document.querySelectorAll(selector);
   }
  })();
  
  function test2(selector) {
   return document.querySelectorAll(selector);
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
test1 body
test1('body')
ready
test2 body
test2('body')
ready
test1 element
test1('span')
ready
test2 element
test2('span')
ready

Revisions

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