ref: 48ded126a9fd399cf2d9c66ee928f4d1d6d065e4
parent: 9d7b044c01680e408094d3bae82f622ae8a5b48b
author: Ben Harris <bjh21@bjh21.me.uk>
date: Sun Dec 11 06:53:17 EST 2022
js: Look up elements in the DOM as early as possible Now that our script is loaded using <script defer>, we can rely on the DOM's being complete as soon as it starts running. So when we declare a variable to point to a DOM element, we can initialise it with that element. This saves having these odd initialisations scattered around the code, usually but not always at the site of first use. I'd like to be able to do the same thing with the variables that point to C functions, but the Module.cwrap() call isn't entirely safe before Emscripten has finished loading the C code.