I am looking to create a javascript \"widget\" that can be hosted on other sites. For example. I want to host the javascript code on my site:
http://scripts.my
I would try to:
Make it configurable
By doing this you let the user decide if he wants your widget to automatically load the stylesheet, or if he wants to host it himself. If he does, he can also update the styles to better fit the page the widget resides on.
ExampleComWidget.addListener('update', callback);Use clever markup
Be sure to use scoping on your classes and ids, to avoid conflicts as much as possible
I.e. if your company's name is example.com, you could use classes like: com-ex-widget-newsItem
-tags, since they have especially high ranking in SEO. You could probably get by with using and less. This bullet might be a bit off. When in doubt, it's much better to use semantic markup than not.