Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3253.3 Safari/537.36
Chrome 64
Windows
Other
7 years ago
Test name Executions per second
getElementById() 3160562.2 Ops/sec
getElementsByClassName() 1999478.8 Ops/sec
getElementsByTagName() 2512389.5 Ops/sec
querySelector(#id) 2221717.2 Ops/sec
querySelector(.id) 664708.6 Ops/sec
querySelectorAll(#id) 1181002.9 Ops/sec
querySelectorAll(.id) 85199.5 Ops/sec
jQuery(#id) 1061408.9 Ops/sec
jQuery(.id) 482204.0 Ops/sec
jQuery(tag#id) 336502.6 Ops/sec
jQuery(tag.id) 66167.5 Ops/sec
jQuery + getElementById 1192094.2 Ops/sec
jQuery + getElementsByClassName 333858.0 Ops/sec
HTML Preparation code:
Tests:
  • getElementById

  • getElementsByClassName

  • getElementsByTagName

  • querySelector (#id)

  • querySelector (.id)

  • querySelectorAll (#id)

  • querySelectorAll (.id)

  • Cash (#id)

  • Cash (.id)

  • Cash (tag#id)

  • Cash (tag.id)

  • Cash + getElementById

  • Cash + getElementsByClassName

  • jQuery (#id)

  • jQuery (.id)

  • jQuery (tag#id)

  • jQuery (tag.id)

  • jQuery + getElementById

  • jQuery + getElementsByClassName