Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.75 Safari/537.36
Chrome 73
Linux
Desktop
5 years ago
Test name Executions per second
getElementById() 3950249.5 Ops/sec
getElementsByClassName() 2663292.0 Ops/sec
getElementsByTagName() 3143114.5 Ops/sec
querySelector(#id) 2238845.2 Ops/sec
querySelector(.id) 3135040.8 Ops/sec
querySelectorAll(#id) 831229.5 Ops/sec
querySelectorAll(.id) 962390.9 Ops/sec
jQuery(#id) 1390100.5 Ops/sec
jQuery(.id) 734452.2 Ops/sec
jQuery(tag#id) 370041.6 Ops/sec
jQuery(tag.id) 367230.2 Ops/sec
jQuery + getElementById 1475604.4 Ops/sec
jQuery + getElementsByClassName 625818.4 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