A more efficient way to get the body is to use document.body instead of document.querySelector("body"). Same thing applies to classes. It's faster for the browser to fetch classes with document.getElementsByClassName('container')[0] instead of using document.querySelector(".container").
To make the js use less code I would add the animation css to the body.dark .sun-logo and body.dark .moon-logo instead of toggling the classes on each button.
I intentionally did the toggling because I wanted to create separate classes because of the transform property. The transform property is explicitly stated for the initial position.
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.
A more efficient way to get the body is to use
document.body
instead ofdocument.querySelector("body")
. Same thing applies to classes. It's faster for the browser to fetch classes withdocument.getElementsByClassName('container')[0]
instead of usingdocument.querySelector(".container")
.To make the js use less code I would add the animation css to the
body.dark .sun-logo
andbody.dark .moon-logo
instead of toggling the classes on each button.I intentionally did the toggling because I wanted to create separate classes because of the
transform
property. Thetransform
property is explicitly stated for the initial position.