jComponent / 07. Plugins
Updated: 10. September 2018
Author: Peter Širka

07. Plugins

Professional Support Chat with contributors

+v15 Plugins are targeted for dynamic parts which can be removed when aren't used. Plugins are the best way for dynamic pages, forms, windows, etc. in SPA / Single Page Applications.


Good to know:

IMPORTANT: events or watchers declared in the plugin scope will be removed automatically if the plugin is removed


  • a plugin name can contain a-z chars only (no numbers or white characters)
PLUGIN('name_of_plugin', function(exports) {

    // You can define your custom functions or properties
    exports.myfunction_1 = function() {

    exports.myfunction_2 = function() {

    exports.myfunction_N = function() {

    // 2 way data-binding watcher:
    WATCH('some.path', function(path, value) {
        // ...

    // Events
    ON('some.event', fucntion(req) {
        // ...



PLUGIN('name_of_plugin', function(exports) {

    // A parent element of the <script> element
    // {jQuery}

    // A plugin name
    // {String}



Plugins support only the one delegate destroy. This delegate is executed when the plugin will be destroyed.

PLUGIN('name_of_plugin', function(exports) {

    exports.destroy = function() {
        // is executed when the plugin is destroyed  


How to call plugin exports?

This is very easy, you can use EXEC method:

EXEC('name_of_plugin/myfunction_1', arg1, arg2, argN);

How to get instance of some plugin?

You can get instance of the plugin very easy, just call PLUGIN(name) without second argument, for example:

var exports = PLUGIN('name_of_plugin');
if (exports)

Best practices

  • keep Plugins as independent .html files
  • I recommend to use Plugin names with lower-case