shithub: puzzles

Download patch

ref: 9d7b044c01680e408094d3bae82f622ae8a5b48b
parent: 420663d47790a7e34a1662d679a0c00efdb5b7e5
author: Ben Harris <bjh21@bjh21.me.uk>
date: Fri Dec 9 08:56:12 EST 2022

js: Simpler and more robust startup procedure

Previously, we initialised all of the JavaScript event handlers as soon
at the DOM was loaded, and then called main() ourselves once the
Emscripten runtime was ready.  This was slightly dangerous since it
depended on none of those event handlers' being called before main().
In practice this was difficult because most of the elements the event
handlers were attached to were invisible, but it did limit what event
handlers could safely be used.

Now, the event handlers are initialised from main().  This makes things
work in a sufficiently conventional way that we can just let the
Emscripten run-time call main() in its usual way, rather than involving
ourselves in the minutiae of Emscripten's startup.