News for hackers. Stuff that matters.
Re:GetElementById vs. QuerySelector by chrismorgan on Friday November 26, 2021 @08:46AM (#29350137)
The spec appropriately points out that this is a fragile technique.

Also to avoid any doubt: if something’s called a golfing trick, you almost certainly shouldn’t use it on normal code.

I confess I use this technique on every page on my website, in my carefully-golfed light/dark mode switcher. (https://chrismorgan.info/blog/dark-theme-implementation/ has a slightly-expanded version of it, and uses a more sensible document.querySelector instead.)

There are no comments on this comment yet.