| The global scope polluter has pretty bad performance and interop surprises, you shouldn't depend on it and instead use getElementById even if it's a bit more verbose. It uses a property interceptor which is fairly slow in v8: https://source.chromium.org/chromium/chromium/src/+/main:out... to call this mess of security checks: https://source.chromium.org/chromium/chromium/src/+/main:thi... which has this interop surprise: https://source.chromium.org/chromium/chromium/src/+/main:thi... which in the end scans the document one element at a time looking for a match here: https://source.chromium.org/chromium/chromium/src/+/main:thi... In contrast getElementById is just a HashMap lookup, only does scanning if there's duplicates for that id, and never surprisingly returns a list! |