Plugster Logo

Simple JavaScript micro-framework written over jQuery with event-based communication as a key feature, as well as the ability to manipulate HTML elements without overusing the $ shortcut.

Through the use of the "view" and "controller" concepts, we try to separate responsibilities, implementing strong modularity along the way, and we try to break up HTML design and JavaScript into separate and independent files. Whenever you need to code a new module, you will have to write one HTML file for the view and one JavaScript file for its corresponding controller, which from now on will be known as a Plugster.

Every Plugster can have "outlets" that will act as a link between the controller and the view, allowing us to access the DOM elements in a more elegant and clear way than to use direct jQuery selector sentences.

Important reasons to use Plugster

When we decided to develop the library, we were looking for:
  • A web client library to be used directly from within the browser
  • A way to keep using as many jQuery plugins as already exist to build our web applications
  • A way to avoid the noise caused by the indiscriminate use of "$" selector sentences
  • A simple mechanism to link DOM elements with controllers written in JavaScript
  • A simple and clear way to keep HTML views and JavaScript controllers in separate files
  • An effective way to develop independent UI widgets or modules that communicate through a Pub/Sub mechanism based on jQuery events listeners and triggers
  • A declarative HTML language for subscribing to events from other Plugsters

A little showcase

The following section is a little demonstration of what can be done using the library. It shows how we establish event listeners directly on the HTML view through the "data-on-" attribute, and it also shows how easily we can declare outlets to avoid using the $ shortcut on the controller.

Timer Control Center
                                    
                                        <div class="has-text-centered"
                                             data-controller-name="ControlCenterPlugster"
                                             data-on-timerplugster-timerpaused="handlePauseCommand"
                                             data-on-timerplugster-timerresumed="handleResumeCommand">
                                            <div class="subtitle">Timer Control Center</div>
                                            <div data-outlet-id="buttonsList" class="buttons is-centered">
                                                <button data-outlet-id="playButton" class="button is-success">Start</button>
                                                <button data-outlet-id="restartButton" class="button is-danger is-hidden">Stop</button>
                                            </div>
                                        </div>
                                    
                                

"Control center" widget (Plugster) to start and pause the clock timer placed just below.

0s
                                    
                                        <div class="has-text-centered"
                                             data-controller-name="TimerPlugster"
                                             data-on-controlcenterplugster-timerstarted="handleStartCommand"
                                             data-on-controlcenterplugster-timerpaused="handlePauseCommand"
                                             data-on-controlcenterplugster-timerresumed="handleResumeCommand"
                                             data-on-controlcenterplugster-timerrestarted="handleRestartCommand">
                                            <div data-outlet-id="timerLabel" class="subtitle is-clickable">0s</div>
                                        </div>
                                    
                                

Timer widget controlled by the timer control center displayed above, and also by itself.

Resources