This one is short but so good that I find myself having to reintroduce it in every project I work on and to most developers I work with.
The Right Way™ to do this is by prefixing those classes with
js- to differentiate them from “real” classes. Note that this does mean I sometimes will have an element with 2 classes, e.g.
- Never fear removing a CSS classes because it might break some script that’s using it
- Never fear renaming or moving a class when you change scripts because it might break the styles