on click
fetch /whatever as json
put the result's data into #some-div
wait 2s
put '' into #some-div
You don't have to mark the script as sync or async, and the runtime will resolve everything for you, making everything feel like synchronous scripting.This obviously has limitations and foot guns, but it works reasonably well for light scripting. More info here:
https://hyperscript.org/docs/#async
And the implementation of it in the runtime here:
https://github.com/bigskysoftware/_hyperscript/blob/c81b07ce...
https://github.com/bigskysoftware/_hyperscript/blob/c81b07ce...
--
[1] - https://htmx.org/essays/hypermedia-friendly-scripting/