How are you generating responses generally?
With xexprs, you can embed JS in attributes by just making a string, such as
(input ([class "player-initiative-input"]
[type "text"]
[inputmode "numeric"]
[value ,(~a (player-initiative p))]
[oninput
"for (element of
document.querySelectorAll(\".player-initiative-input\")) { if (element
!== this) { element.disabled = true; } }"]))
I think you can also embed cdata
structs via make-cdata
in an
xexpr that is translated by response/xexpr
and friends as "just the
string I meant, no translations."
But I find it convenient to serve the JS as a static file and then
include the right metadata via a script tag. Search for "static" in
https://github.com/benknoble/frosthaven-manager/blob/main/server.rkt.