Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.1 Safari/605.1.15
Safari 18
Mac OS X 10.15.7
Desktop
one month ago
Test name Executions per second
getElementById() 12466793.0 Ops/sec
getElementsByClassName() 10529344.0 Ops/sec
getElementsByTagName() 10486617.0 Ops/sec
querySelector(#id) 5575179.5 Ops/sec
querySelector(.id) 5782625.5 Ops/sec
querySelectorAll(#id) 3628498.2 Ops/sec
querySelectorAll(.id) 7159833.5 Ops/sec
jQuery(#id) 6717068.0 Ops/sec
jQuery(.id) 4713057.5 Ops/sec
jQuery(tag#id) 2842685.0 Ops/sec
jQuery(tag.id) 2855967.2 Ops/sec
jQuery + getElementById 5638867.5 Ops/sec
jQuery + getElementsByClassName 4731742.0 Ops/sec
jQuery + querySelectorAll 3974278.2 Ops/sec
querySelectorAll in function 7030800.0 Ops/sec
HTML Preparation code:
Tests:
  • getElementById()

  • getElementsByClassName()

  • getElementsByTagName()

  • querySelector(#id)

  • querySelector(.id)

  • querySelectorAll(#id)

  • querySelectorAll(.id)

  • jQuery(#id)

  • jQuery(.id)

  • jQuery(tag#id)

  • jQuery(tag.id)

  • jQuery + getElementById

  • jQuery + getElementsByClassName

  • jQuery + querySelectorAll

  • querySelectorAll in function