this post was submitted on 21 Jan 2026
372 points (99.2% liked)
Programmer Humor
28669 readers
1851 users here now
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
If your element has an id, you can just reference it from the window scope. The
const page =is useless. Also the body has its own reference under document:document.bodyreplacesdocument.querySelector('body')This is brittle, as defining a global variable with the same name (or the browser adding a API with the same name) will override it. This functionality was only kept for backwards compatibility with sites designed for Internet Explorer. The spec says to use
getElementByIdinstead.Aww man. I only found out about this recently :(
I knew about this feature yeah but it seemed too janky to me (which says something, you should see the rest of my project :P)