It’s probably because you have to wait for the library to load before you can use it. Here is some code that loads the library and makes a sweet alert once it’s loaded:
function loadScript(id, url)
{
// i find promises more cleaner than callback functions
return new Promise((resolve, reject) => {
// Adding the script tag to the head as suggested before
var head = document.head;
// check if script is already loaded
var script = document.getElementById("SCRIPT-" + id);
// if script is loaded, terminate function
if (script) {
resolve.call(script);
return;
}
script = document.createElement('script');
script.type = 'text/javascript';
script.onload = resolve;
script.onerror = reject;
// name this script so future calls can check if it is already loaded
script.id = "SCRIPT-" + id;
script.src = url;
// Fire the loading
head.appendChild(script);
});
}
loadScript("sweetalert", "https://unpkg.com/sweetalert/dist/sweetalert.min.js")
.then(() => {
window.swal("SWEET ALERT", "Loaded the Sweet Alert library", "success");
});
Also you could make dialog boxes in Wick Editor instead of using an external library.