Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
id vs attribute
(version: 1)
Comparing performance of:
beginning with attribute selector vs attribute selector vs id selector
Created:
one year ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<div id="variableContainerSso"></div>
Script Preparation code:
/*your preparation JavaScript code goes here To execute async code during the script preparation, wrap it as function globalMeasureThatScriptPrepareFunction, example:*/ async function globalMeasureThatScriptPrepareFunction() { // This function is optional, feel free to remove it. // await someThing(); }
Tests:
beginning with attribute selector
document.querySelector("div[id^='variableContainerSso']")
attribute selector
document.querySelector("div[id='variableContainerSso']")
id selector
document.querySelector("#variableContainerSso")
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
beginning with attribute selector
attribute selector
id selector
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
12 days ago
)
User agent:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:150.0) Gecko/20100101 Firefox/150.0
Browser/OS:
Firefox 150 on Ubuntu
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
beginning with attribute selector
2605606.8 Ops/sec
attribute selector
2769202.2 Ops/sec
id selector
3313027.2 Ops/sec
Related benchmarks:
get navigation type
Assigning new variable
Test array concat
213find vs findIndex vs some (Array prototype methods)
undefined to boolean
Nullish vs If
JS Variable Performance (const vs let vs var)
Reflect.get vs direct access
Regex starts with A or B vs startsWith
Comments
Confirm delete:
Do you really want to delete benchmark?