Skip to content

Basic usage

Milos Stanojevic edited this page Mar 14, 2020 · 5 revisions

Importing the library

You can either download Supercharge.js and host it yourself or use jsdelivr and github as CDN to host it for you. Simply add this line to your HTML document before the </body> tag.

<script src="https://cdn.jsdelivr.net/gh/pointermess/Supercharge.js@v0.1/src/Supercharge.min.js"></script>

To automatically get the latest version you could use this link: (this is not recommended in production)

<script src="https://cdn.jsdelivr.net/gh/pointermess/Supercharge.js/src/Supercharge.min.js"></script>

Hello World

Supercharge comes with a factory class which helps building the structure of an application. We can build a basic Hello World application using the SuperchargeFactory.build function and passing an object.

let app = SuperchargeFactory.build({
    'tag': 'div',
    'body': 'Hello World from Supercharge.js!',
    'onClick': function (e) {
        alert('Mouse Coordinates: ' + e.clientX + ' , ' + e.clientY);
    }
});

Mounting our application

Before our application appear on the site, we have to mount it first. Supercharge.js provides ways to mount and unmount our application.

// mounting the application
app.mount(document.body);

You can also unmount your application / element.

// unmounting the application
app.unmount();
Clone this wiki locally