Run details:
Mozilla/5.0 (X11; CrOS x86_64 11895.118.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.159 Safari/537.36
Chrome 74
Chrome OS 11895.118.0
Desktop
5 years ago
Test name Executions per second
getElementById() 3066831.2 Ops/sec
getElementsByClassName() 2112299.5 Ops/sec
getElementsByTagName() 2431418.0 Ops/sec
querySelector(#id) 1778472.6 Ops/sec
querySelector(.id) 2281127.0 Ops/sec
querySelectorAll(#id) 718353.4 Ops/sec
querySelectorAll(.id) 844091.6 Ops/sec
jQuery(#id) 1127602.6 Ops/sec
jQuery(.id) 539281.1 Ops/sec
jQuery(tag#id) 325973.0 Ops/sec
jQuery(tag.id) 323301.6 Ops/sec
jQuery + getElementById 1245408.1 Ops/sec
jQuery + getElementsByClassName 495232.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