Sweet Alert - Importing JS Plugins

To import a JS Plugins you’d need this code:

Import Code
function loadScript(url)
{
    // Adding the script tag to the head as suggested before
    var head = document.head;
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = url;

    // Fire the loading
    head.appendChild(script);
}

onEvent('load', function () {
  loadScript("SCRIPT URL");
});

From THIS Stack Overflow question

To run the function of the imported script use:
window.function_name()
NOTE: After importing, and if the imported function is on the same scope and time as the loadScript call… please put a delay on it; importing takes time (like the example below). And internet is required.

Sweet Alert Plugin Example File:
Sweet Alert JS Example3-9-2020_4-58-59PM.wick (1.4 KB)
Tested on wick editor 1.16.2, 1.17, and itch.io

2 Likes