What is a Plugin and why create one?
A plugin is a class that adds functionality/features to a parent component by adding or modifying its behaviour and/or look after its instatiation. By creating a plugin you can reuse it and apply its behaviour to any number of components without duplicating code and effort. To use a plugin in a component you simple instantiate it in the component’s ‘plugin‘ config option. An example of a plugin might be one which adds a help icon after each form field providing the user with help text on how to fill it in. If you didn’t create a plugin for it you would be required to manually code it for each form field which would be cumbersome and time consuming. So, hopefully I’ve convinced you of the merits of creating plugins to allow maximum code reuse and to make your lift a whole lot easier! Now how do we actually create one…?