Initializing Plugins

Many third-party plugins require initialization, or will fail if they load before the DOM (Document Object Model) is rendered. The Developer Portal emits two custom events that you can listen for, before initializing, or loading your scripts.
Event When it runs
prerender After all core files and API calls have completed, but before rendering the UI.
render After the UI has finished rendering.
For example, if you had a plugin call createTableOfContents() that required the DOM to be fully loaded before running, you would do this:
// After the UI renders
portal.on('render', '#app', function () {

    // Load the JS file
    portal.loadJS('/path/to/createTableOfContent.js', function () {

        // One it loads, run it
        createTableOfContents();

    });

});