Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36
Chrome 64
Linux
Other
2025 years ago
Test name Executions per second
getElementById() 1765058.0 Ops/sec
getElementsByClassName() 1002970.2 Ops/sec
getElementsByTagName() 1329167.0 Ops/sec
querySelector(#id) 1390030.5 Ops/sec
querySelector(.id) 352523.5 Ops/sec
querySelectorAll(#id) 542652.5 Ops/sec
querySelectorAll(.id) 48327.3 Ops/sec
jQuery(#id) 418541.6 Ops/sec
jQuery(.id) 229941.5 Ops/sec
jQuery(tag#id) 156059.0 Ops/sec
jQuery(tag.id) 38461.7 Ops/sec
jQuery + getElementById 578095.8 Ops/sec
jQuery + getElementsByClassName 161634.8 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