Some basic key points to remember are as follows:
jQuery documentation is your best friend. Always go back to the documentation pages when in trouble or in need of information. Reading it thoroughly wouldn't hurt, either.
It might sound stupid, but always remember to link to the
jquery.js
file (containing the jQuery library) or, no matter what, we might spend hours looking for some error that justifies the script not running or working properly.Always prefer the document-ready statement to any other non-jQuery functions to check whether the page has already loaded or not. Enough said.
This can never be stressed enough: plugins based on methods are completely different to plugins based on functions.
Method plugins extend the
jQuery.fn
object.Function plugins extend the
jQuery
object directly.Method plugins do support chainability.
Function plugins do not support chainability.
Method plugins should always return the
jQuery
object (this
, in the code), to allow for chainability.
Also refer back to Chapters 2 and 3 for more details.
As a plus, Keith Wood has written a very useful article about the plugin framework that he makes use of when developing plugins, which you may find interesting.
The article, which can be found at http://keith-wood.name/pluginFramework.html, is an extremely detailed dissertation covering all a developer needs to know about the jQuery plugin structure. It deals with singletons, event binding, settings, and destroy functionalities. It is a must-read for all jQuery plugin developers out there.