HTML Preparation code:
Tests:
  • getElementById

  • querySelector("#id")

  • getElementsByClassName("class")[0]

  • querySelector(".class")

  • getElementById + getElementsByTagName

  • querySelectorAll("#id tag")

  • getElementById + getElementsByClassName[0]

  • querySelector("#id .class")

  • getElementsByClassName("class")

  • querySelectorAll(".class")

Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results
  • Test case name Result
    getElementById
    querySelector("#id")
    getElementsByClassName("class")[0]
    querySelector(".class")
    getElementById + getElementsByTagName
    querySelectorAll("#id tag")
    getElementById + getElementsByClassName[0]
    querySelector("#id .class")
    getElementsByClassName("class")
    querySelectorAll(".class")

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 7 years ago)
Mozilla/5.0 (Windows NT 10.0; WOW64; rv:55.0) Gecko/20100101 Firefox/55.0
Firefox 55 on Windows
View result in a separate tab
Test name Executions per second
getElementById 239449.8 Ops/sec
querySelector("#id") 233847.6 Ops/sec
getElementsByClassName("class")[0] 232259.4 Ops/sec
querySelector(".class") 123337.0 Ops/sec
getElementById + getElementsByTagName 2069198.4 Ops/sec
querySelectorAll("#id tag") 57407.4 Ops/sec
getElementById + getElementsByClassName[0] 0.0 Ops/sec
querySelector("#id .class") 0.0 Ops/sec
getElementsByClassName("class") 2327024.8 Ops/sec
querySelectorAll(".class") 48054.1 Ops/sec


;