Guys, you don't need all that JS, seriously. It's slow, it's useless most of the time. And in the end you have to spend hours for something so simple.
Theming the colors of your website is the role of one tech: CSS. That's it, you don't needs layers and layers of Javascript to change that.
Let's go back to server side rendering, a bit of HTML + CSS and JS and we're done.