While I am not aware of any open source framework doing this, as long as the programmer holds itself to a few basic rules, this should be possible.
If all html/js/css is generated by a template language, you keep the css classes easily parsable and you avoid using dynamic classnames in js (data properties are better for that anyway),
you can just replace all classes with random ids.
In fact this is how gettext() works.