This is a very old question. SweetAlert may have been non blocking originally. I have recently (April 25, 2025) downloaded it. I am able to have it block, be synchronous. It uses Promises.
async function foo()
{
if ( await yesno( "Answer Yes or No" ) {
// They answered YES
} else {
// They answered NO
}
}
async function yesno( question )
{
var rtn;
await swal({
closeOnEsc: false,
closeOnClickOutside: false,
text: question,
buttons: {
no: { text: "No", value: 0 },
yes: { text: "Yes", value: 1 },
},
}).then( value => {
switch (value) {
case 1:
rtn = true;
break;
case 0:
default:
rtn = false;
break;
}
});
return rtn;
}