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) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36
Chrome 55 on Windows
View result in a separate tab
Test name Executions per second
getElementById 306914.6 Ops/sec
querySelector("#id") 290923.1 Ops/sec
getElementsByClassName("class")[0] 301745.1 Ops/sec
querySelector(".class") 192167.2 Ops/sec
getElementById + getElementsByTagName 82686.9 Ops/sec
querySelectorAll("#id tag") 69106.5 Ops/sec
getElementById + getElementsByClassName[0] 285188.7 Ops/sec
querySelector("#id .class") 282789.2 Ops/sec
getElementsByClassName("class") 83912.9 Ops/sec
querySelectorAll(".class") 42237.8 Ops/sec


;