When creating a jQuery plugin it’s nice to have a starting point to work from. A boilerplate serves as a nice small piece of code that you can pop in, allowing you to start working on your plugin right away. It also servers as a solid foundation to build your jQuery plugin off of knowing that the code is more stable.
A good boilerplate to start off with is the Websanova wBoiler which is freely available on GitHub. It comes with solid features out of the box, some of which include:
- option setting – allowing you to set options using the
data-
attribute, default options or via setter and getter methods. - multiple themes – a nice utility allowing developers to add and remove multiple themes on the fly.
- structure – a solid structure for developing your plugin such as defaults and HTML5 support.
- mobile – a tried and tested mobile support function which maps mouse to touch events.
The list could go on but the best thing is to just jump right in and try it out for yourself. It’s always better to start with a piece of code that’s been tested and will avoid some of the common pitfalls you will encounter as you are creating your jQuery plugin.