You don't need any JS for dark mode switching, easily do it with CSS only: css-tricks.com/dark-modes-with-css/
You might want to combine that CSS with a cookie or something to omit the switch over if someone explicitly switches for a site.
True. But this was a beginners guide so I didn't want to do anything extra.
I'm aware of that method but it has little support with most browsers and as such is unusable in a production website/web app.
But like I said initially, there are several ways to go about implementing anything.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You don't need any JS for dark mode switching, easily do it with CSS only: css-tricks.com/dark-modes-with-css/
You might want to combine that CSS with a cookie or something to omit the switch over if someone explicitly switches for a site.
True. But this was a beginners guide so I didn't want to do anything extra.
I'm aware of that method but it has little support with most browsers and as such is unusable in a production website/web app.
But like I said initially, there are several ways to go about implementing anything.