Creating a plugin template

Creating jQuery plugins has become very popular over the years, and there are many articles and discussions online about plugin creation best practices. Many of these articles discuss in depth how to create a plugin template that can be used as the starting point for any jQuery plugin. This recipe will show you how to create your own jQuery plugin template that will be used throughout this chapter.

Getting ready

Inside the chapter8 folder that was created earlier, create a JavaScript file called jquery.plugin-template.js.

How to do it…

To create a basic plugin template that will form the basis of all the plugins used within this chapter, add the following code to jquery.plugin-template.js:

;(function ($) { var name = 'pluginName'; ...

Get jQuery 2.0 Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.