Dec 10, 2022
I was writing a reply to this that ended up critiquing my own appraoch as well, so I made an article out of it:
https://medium.com/@deathshadow/lets-make-a-better-light-dark-toggle-760499a8bc82
Mostly the use of SVG and anim.js is wasteful here, and the use of scripting only garbage in the markup with no scripting off fallback plan really makes this bad...
Though at the same time your example's overall simpler concept has a good deal of merit when it comes to explaining code to people.
Thus my own article about it.