Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
getElementById raw vs function
(version: 1)
Benchmark.js
Comparing performance of:
getElemntByID vs with function
Created:
8 days ago
by:
Guest
Go to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here--> <div id="elementWithId"></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(); } const el = (id) => document.getElementById(id)
Tests:
getElemntByID
/*When writing async/deferred tests, use `deferred.resolve()` to mark test as done*/ const element = document.getElementById("elementWithId")
with function
const element = el("elementWithId")
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
getElemntByID
with function
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
8 days ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:155.0) Gecko/20100101 Firefox/155.0
Browser/OS:
Firefox 155 on Mac OS X 10.15
View result in a separate tab
Embed
Embed Benchmark Result
with function
1580.4M/s
getElemntByID
10.9M/s
View exact numbers
Test name
Executions per second
✓
with function
1,580,440,960 Ops/sec
getElemntByID
10,922,854 Ops/sec
Related benchmarks
Multiple .closest() or complex CSS selector
Query Element
Test id vs next sibbling
set: innerHTML vs outerHTML
createElement vs DOMParser
insertAdjacentHTML vs appendChild 2025
document.createElement : direct assign vs Object.assign vs setAttribute
querySelector vs getElementById
querySelector v getElementById
Comments
Confirm delete:
Do you really want to delete benchmark?