Shopify ScriptTag after uninstallation
The Shopify ScriptTags are async in nature which is why your ScriptTag is loaded after the dom is ready. If you want to avoid it, then you will need to write the ScriptTag in the theme.liquid file.
However, as soon as, merchant uninstalls the app, theme access is revoked and hence it will keep hitting your server. To avoid that make sure to truncate (empty) the content of the script. Do not delete it! If you delete it, merchant will get 404 error and might leave a one star review because of their lack of knowledge.
There is no way to delete it from theme but you can send email to the merchant asking him to delete the code. Other way is to provide an uninstallation option within your app which will delete the snippet from the theme first and then uninstall itself.