Run details:
Mozilla/5.0 (X11; CrOS x86_64 11895.74.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.90 Safari/537.36
Chrome 74
Chrome OS 11895.74.0
Desktop
5 years ago
Test name Executions per second
getElementById() 3836354.5 Ops/sec
getElementsByClassName() 2517062.2 Ops/sec
getElementsByTagName() 2897987.8 Ops/sec
querySelector(#id) 2071834.5 Ops/sec
querySelector(.id) 2226899.0 Ops/sec
querySelectorAll(#id) 431033.1 Ops/sec
querySelectorAll(.id) 743019.9 Ops/sec
jQuery(#id) 1086853.0 Ops/sec
jQuery(.id) 604315.1 Ops/sec
jQuery(tag#id) 341380.8 Ops/sec
jQuery(tag.id) 363712.2 Ops/sec
jQuery + getElementById 1288231.1 Ops/sec
jQuery + getElementsByClassName 548002.5 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