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.mysite.com/mywidget.js
(Think of it like Google Analytics).
Basically I want to distribute data via this javascript. But what I am unsure of is:
You can create a widget that acts on a default value, selected Live Text, or other selected text using a single form on a specific Web page. Or you can create a widget that can perform one or more actions based on an overall Web page.
You use the JavaScript widget to embed JavaScript code in your page. JavaScript is used to enhance the functionality of your website. For example, you can use JavaScript to validate user input. After you place the JavaScript widget on your page, you configure which JavaScript to include.
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
<h1>
-tags, since they have especially high ranking in SEO. You could probably get by with using <h4>
and less. This bullet might be a bit off. When in doubt, it's much better to use semantic markup than not.Your script should not interfere with the rest of the page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With