Rabu, 09 Februari 2011

jquery programming and jquery plugin authoring commandments

jQuery Commandments

You shall not instantiate more than one jQuery object containing the same set of nodes.,

You shall not re-query the DOM for a given selection at any time unless it is suspected that the returned collection will have changed since the last query.,

You shall place scripts dependent on the readiness of the DOM at the bottom of the document.,

You shall favor CSS3 selectors over jQuery's psuedo-classes and special filters.,

You shall not use browser detection or browser inference.,

You shall use the correct spelling of jQuery and honour the capitalisation of its Q in any correspondence relating to it.,

You shall isolate any issues you have before posting to IRC or a forum, and especially before opening a ticket in the bug tracker.,

You shall, when requiring a reference to a DOM node created by yourself, gain that reference prior to DOM injection.,

You shall favor event delegation when the event in question propagates and when there are a substantial number of elements to be bound to.,

You shall not use jQuery when a faster and terser solution exists in the native DOM API.

jQuery Plugin Authoring Commandments

You shall return a jQuery object unless the method is intended to return something else.,

You shall return the instance on which the method is being called unless you wish to mutate the collection, in which case you should use the pushStack method to return a new jQuery instance.,

You shall make configuration accessible under the plugin's namespace.,

You shall make it possible to override the configuration on a per-call basis.,

You shall not use the globally defined dollar identifier.,

You shall not pollute namespaces unrelated to the plugin.,

You shall namespace any events binded to by the plugin.,

You shall remember that one configurable callback function is better than ten specific configuration options.,

You shall document the plugin.,

You shall respond gracefully should a jQuery instance contain no elements.

source: https://github.com/jamespadolsey/jQuery-Commandments

Tidak ada komentar:

Posting Komentar