|
|
|
|
|
by esprehn
1669 days ago
|
|
Browsers do exactly the optimization you're describing:
https://source.chromium.org/chromium/chromium/src/+/main:thi... Both getElementById and querySelector are quite fast, down to the level of measuring individual branches in a micro benchmark. querySelector does have to do a bit more work to lookup the cached query and a handful of extra branches over getElementById, it's not scanning the document for an ID query unless you're in quirks mode though. |
|