Hi Alex,
You can use Shopify's ScriptTag API to request your script to be loaded on the shop's page. To the best of my knowledge, the script will be loaded asynchroniously, from a Shopify's code that runs in document's head, so essentially, it will be executed after the page has been loaded, similarly to what you require.
https://docs.shopify.com/api/uiintegrations/scripttag
Also, if all your app needs to do is injecting your script into the page, you can easily build this with Inffuse, which we're building to help app developers. It will take care both of injecting the script, and app's authentication process. If you need some configuration parameters that's also easily done, using Javascript only. We're in closed beta right now, but feel free to email me to sasha<at>inffuse.com for further info or an invite.