Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
Chrome 71
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 3200012.0 Ops/sec
getElementsByClassName() 2122716.5 Ops/sec
getElementsByTagName() 2591566.0 Ops/sec
querySelector(#id) 1878350.1 Ops/sec
querySelector(.id) 2483852.5 Ops/sec
querySelectorAll(tag#id) 720099.1 Ops/sec
querySelectorAll(.id) 952701.6 Ops/sec
jQuery(#id) 1073269.1 Ops/sec
jQuery(.id) 524750.3 Ops/sec
jQuery(tag#id) 282727.9 Ops/sec
jQuery(tag.id) 286523.3 Ops/sec
jQuery + getElementById 1211657.9 Ops/sec
jQuery + getElementsByClassName 488558.9 Ops/sec
HTML Preparation code:
Tests:
  • getElementById()

  • getElementsByClassName()

  • getElementsByTagName()

  • querySelector(#id)

  • querySelector(.id)

  • querySelectorAll(tag#id)

  • querySelectorAll(.id)

  • jQuery(#id)

  • jQuery(.id)

  • jQuery(tag#id)

  • jQuery(tag.id)

  • jQuery + getElementById

  • jQuery + getElementsByClassName