Speed: document.head is much slower than document.querySelector('head') |
||
Issue description
Intuitively, one might think document.head would be the fastest way to obtain a reference to <head>. However, in Chrome (and Firefox/Safari), querySelector('head') is 40-75% faster.
Benchmark:
https://esbench.com/bench/5c12ae1e4cd7e6009ef61df3
Tweet (context + developer sentiment):
https://twitter.com/_developit/status/1073301597168513029
Implementation: (head is a getter on Document)
https://cs.chromium.org/chromium/src/third_party/blink/renderer/core/dom/document.cc?sq=package:chromium&g=0&l=3301-3307
,
Dec 14
Yes - sorry, this got debunked pretty thoroughly on Twitter and I should have closed the issue as well. The test breakage seems likely to be due to reuse of the test iframe. |
||
►
Sign in to add a comment |
||
Comment 1 by woxxom@gmail.com
, Dec 14