Problem
I am writing a javascript library. Some functions append quite a bunch of elements to the document. I'm choosing not to style these all individually through javascript since it's using up a lot of execution time. Instead, I will give all appended elements one or more specific classnames or ids (difference doesnt matter in this context) and then define the style in a pregenerated stylesheet.
This practice could induce collisions in class/id naming. Imagine a user of the library already having defined a #foo in another stylesheet or a .bar getting defined in a javascript from another library.
A solution to this would be to prefix classnames to minimize the chance of a collision. Although this doesn't reduce the chances of it happening to 0. Would there be another method of avoiding this through javascript?