I built a tiny JavaScript library providing async alternatives to the built-in blocking browser APIs alert() and confirm() and prompt() https://simonwillison.net/2024/Dec/7/prompts-js/
await Prompts.alert(
"This is an alert message!"
);
const confirmedBoolean = await Prompts.confirm(
"Are you sure you want to proceed?"
);
const nameString = await Prompts.prompt(
"Please enter your name"
);
I got the new OpenAI o1 to do most of the heavy lifting - it's really useful for this kind of exploration
@simon Just noting that these are nowhere near as accessible as the built-in, non-async versions, particularly with a screen reader. A totally fixable problem, just wanted to make you aware.