views:

42

answers:

2

Hi,

While creating a jQuery widget, what convention should I use to name my CSS classes. jQuery uses a 'ui-' prefix followed by the plugin name and a class specific name (example : ui-datepicker-header).

Should I use this convention? Or is the 'ui' prefix "reserved" for jQuery's official use only?

A: 

When deciding things like this, think about how someone knowing nothing about your code would read it.

I wouldn't use the "ui-" prefix because such a person might think it's jQuery UI related.

You don't need to use a prefix. In most cases this is "noise". If everything starts with "foo-" why have it? It makes sense for a library because then you can easily distinguish what "belongs" to the library. For your own code, it's assumed that everything that doesn't belong to a library belongs to your application.

Pick a meaningful name for each thing that is short but not too short.

cletus
The problem is I would not want my css class names to collide with other widgets/libraries. This being said, this kind of collision would not be too hard to workaround if someone ever meet them.
Mathieu Pagé
A: 

Avoid using "reserved" one, use your own but make sure that overall name does not conflict with any of existing plugins/widgets.

Sarfraz