If you've spent any time developing code in jQuery, then it is very likely that you've created one or more plugins; these can technically range from just a handful of lines to something more substantial.
Over time, there is a risk that amending code in plugins can lead to content becoming unwieldy and difficult to debug. One way of dealing with this is to use design patterns. We covered this back in Chapter 3, Organizing Your Code. Many of the same principles can equally apply to plugins, although the patterns themselves will of course be different. Let's consider a few examples.
The most basic pattern is A Lightweight Start, which will suit those who have developed plugins before, but are new to the concept of following a specific pattern. This particular pattern is based around common best practices, such as using a semicolon before invoking the function; it will pass in standard arguments such as window
, document
, and undefined
. It contains a basic default object...