Most people today use either the
classList or the
The answer is CSS variables, or CSS custom properties as some people like to call them. Because while CSS variables are also manipulated via the
Using event listeners to change the variables is crazy smooth, here's an example I wrote a few weeks ago (using variable fonts, which are also v. cool!):
Another big advantage of CSS variables is that you can set variables on the parent element which all children elements can read, and subsequently also the
:after pseudo selectors. This does make adding a new variable slower when there are a lot of child elements though!
Especially animations based on mouse position work really well in my opinion:
So CSS variables are supported among most browsers, except for of course... IE. But seriously, even microsoft is telling people to stop using IE11. As long as you use the animations for enhancement purposes only, your users --even those who torture themselves with IE-- should be fine.