Widget -what to do and what not
NickName:mkoso Ask DateTime:2010-03-03T04:33:52

Widget -what to do and what not

I would like to make a html/js widget that people can add to their blogs, sites etc.

I have never made widgets before so I would like to hear what should be done and what not. For example, how do I make the styling? Inline, own css file or what is the best practise? I believe i cant use head and body stuff in it. What about h1, h2 etc? Do they screw the website that has the widget or can i use them?

If you have any good tips I would like to hear those.

Thanks.

Copyright Notice:Content Author:「mkoso」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/2366539/widget-what-to-do-and-what-not

Answers
PatrikAkerstrand 2010-03-02T20:54:28

I would try to:\n\n\nMake it configurable\n\n\nLoad external stylesheets?\nWhere do I find resources I need? (images, stylesheets)\nWhat layout/size should I have?\n\n\nBy 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.\nProvide a wizard for generating a snippet of code to include on the page\n\n\nEnsures that even moderately technical users can utilize your widget\n\nMake it light-weight\n\n\nServe everything minified and compressed\nServe with cache-headers, e-tags, last-modified and all other useful headers you can think of. This will both reduce the load on your servers as well as make your widget more responsive.\nTry to avoid dependencies on libraries, or check if they are loaded on the page where the widget is used before loading them\n\nBe wary of conflicts\n\n\nPrototype uses $, and so does jQuery. If your widget depends on Prototype, and the page it is hosted on uses jQuery without noConflict-mode, problems WILL arise\nDo not clobber the global namespace!\n\n\nIf you don't want anyone to interact with your widget, put it in a self-executing function in a closure and don't create any global variables at all\nIf you want users to be able to interact with your widget, say for adding event listeners and such, claim a single global variable, let's say ExampleComWidget as an object literal and put your methods there. User's could then interact like: ExampleComWidget.addListener('update', callback);\n\n\nUse clever markup\n\n\nBe sure to use scoping on your classes and ids, to avoid conflicts as much as possible\n\nI.e. if your company's name is example.com, you could use classes like: com-ex-widget-newsItem\nValidate your markup! You do not want to break a user's site\nSemantic markup is fine, but you might want to avoid <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.\n\n",


More about “Widget -what to do and what not” related questions

Widget -what to do and what not

I would like to make a html/js widget that people can add to their blogs, sites etc. I have never made widgets before so I would like to hear what should be done and what not. For example, how do ...

Show Detail

What is a Widget in Flutter?

The Flutter tutorial uses the word "Widget" everywhere. What is a widget in that context? The closest question I could find on this on SO is here: What is a widget in Android? But it is about Andr...

Show Detail

android widget, what to do after configure activity

i have a pretty standard android widget, that starts it's configure activity, where you can set up several options. now what should i do after the setup is finished. cause when i press the back or...

Show Detail

What is a widget in Android?

What is a widget in android? Can I develop a widget for my app?

Show Detail

What android widget is this?

does anybody know what android widget/view this is: i want to be able to implement a similar widget for my own needs but i dont know what kind of view/widget it is. All i see is that it is embeded...

Show Detail

What exactly is a widget?

I found some conflicting definitions on the term. On http://developer.android.com/reference/android/view/View.html, the author defined widgets as "View is the base class for widgets, which are used...

Show Detail

What is widget testing?

I just started with testing in flutter i am writing unit tests for my business logic. I am also familiar with mocking dependencies, however widget testing is quite overwhelming? In Widget testing w...

Show Detail

What is this widget in Qt called?

I am looking for a widget, but I don't know what the name of it is. It's a number field with little arrows on the side. When you click an arrow, the number will either increase or decrease. What is...

Show Detail

What is a widget container?

I have searched about this on the net, but have not been able to find a good explanation. What is a widget container, why is it used?

Show Detail

What is the android lockscreen widget lifecycle?

I have an app widget and enabled it as a lockscreen widget by adding "keyguard" to the widgetCategory attribute of the app widget provider xml. I added a debug view to my widget to display a times...

Show Detail