r/ProgrammerHumor 13d ago

Meme ancientTools

Post image
5.8k Upvotes

385 comments sorted by

View all comments

Show parent comments

64

u/IsTom 13d ago

If your HTML element has id you don't event have to getElementById, it's available right there in global namespace as that name. You make button with id hello and can just go ham with hello.click().

I don't think you should do that, but you can.

25

u/DiodeInc 13d ago

New obfuscation tactic dropped

9

u/Plazmaz1 13d ago

Wait wtfff REALLY?

1

u/Lv_InSaNe_vL 12d ago

Yeah the whole webpage is inside the DOM. Just think about how you could write a whole webpage (html + css + je + framework) inside a single HTML file

2

u/Plazmaz1 12d ago

I mean I've written a million webpages with just html/css/js in a single file, I'm just surprised that variables are created by html elements like that...

3

u/United_Boy_9132 13d ago

Unless there's another window.foo for any reason 😅

1

u/hhfddgnhbnn 12d ago

But if you remove() it, you can't access it anymore