• If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Whenever you search in PBworks or on the Web, Dokkio Sidebar (from the makers of PBworks) will run the same search in your Drive, Dropbox, OneDrive, Gmail, Slack, and browsed web pages. Now you can find what you're looking for wherever it lives. Try Dokkio Sidebar for free.


Coding standards

This version was saved 11 years, 7 months ago View current version     Page history
Saved by Scott González
on October 12, 2011 at 7:27:17 am
NOTE:  Content from the old Development page has been ported into this page to avoid any confusion. This page is in-progress and we'll be making additions frequently so please check back for updates. Please note any questions or claifications here so they can be answered.


General Guidelines


  • Follow all jQuery Core Style Guidelines
  • Do not use jQuery.browser, use jQuery.support instead. Create new support tests if needed.
  • Plugins must work regardless of what options are passed to init.  All options are truly optional and may be changed at any time.
  • Use jQuery.ui.keyCode for all keyboard events.
  • Do not abbreviate variable names; the bytes will be saved when compressed.
  • Do not modify options that a user passes in, except when they are used to reflect the state of the plugin.
  • All default values must be explicit.
    • If the default behavior is to parse the DOM for a value, then null should be used for the default. 
    • No default value should be undefined.
    • Defaults should be specified in alphabetical order, with callbacks grouped at the bottom. 
  • Don't save any data on the element other than the plugin instance.
    • An exception to this rule is if you need to store data on subordinate elements.
  • Use HTML, not XHTML .
    • Use <!doctype html> to trigger standards mode and <meta charset="utf-8">.
    • Use valid HTML, ie <div></div> not <div/>.



.noConflict() compliance


Wrap plugins in a closure that passes jQuery in as a parameter. Inside the closure, only reference jQuery through the parameter variable.


(function( $ ) {

     // inside here only reference $, not jQuery

}( jQuery ) );



passing elements as options or parameters


Whenever a user can specify an element, they should be able to provide any of the following:

  • DOMElement
  • array of DOMElement's
  • jQuery object
  • function that returns any of the above
    • Is there a common set of parameters that would be passed to this function?
    • Is there a common context that would be set for this function?
  • See #4957



TODO: move everything below here to widget factory docs and link to that doc from here.


getting/setting options after init


add notes about how to listen to options




add notes about how to trigger callbacks and what to pass in the ui object


specifying icons


add notes about how to specify which icons to use, e.g., which close icon.


specifying events


add notes about how to specify which events should trigger an action

- click, ctrl+click, mouseover


applying CSS classes


- applying hover states

- applying focus states


Comments (0)

You don't have permission to comment on this page.