What do you mean by 'when the runtime was loaded'?
I use --pre-js and --post-js to have fine-grained control over running order.
You could modify this by putting the stuff in post-js inside a function itself which you could insert into window as 'initemtcl' or something similar.
Honestly, I'm not sure if those two links are the best way to do this kind of thing any more. I created this structure of pre/post-js about a year and a half ago and I've just copied and pasted since then. For example, I don't know if emscripten still pollutes `window.Module`.
Hopefully it gives you a starting point - basically just wrap everything in a function and run that when you want to kick off.
Aidan