Chapter 4. Plugin principles
This chapter covers
- Plugin design
- Guiding principles for development
The scope for a jQuery plugin is wide open—from basic class changes and event handlers, through selectors and animations, to full-blown graphical widgets with remote access. The only limit is your imagination.
In the previous chapter you saw how to create custom selectors for use in jQuery, giving you some simple examples of one way to enhance its abilities. Now we’ll take a step back and consider the plugin design and creation process as a whole. Whatever type of plugin you choose to create, you should follow best practice principles so that your plugin will survive and prosper within the wider jQuery and JavaScript environments.
This chapter discusses those principles and explains why they should be applied to your plugins. It also looks at the benefits of creating a plugin rather than just coding inline, and presents some questions to consider when designing your own plugin.