When the page loads, all those scripts will be loaded and the new JSONRpcClient() method will be executed during the page load, as expected.
I have tried several solutions for this. The only one I had success with is the following. It’s kind of dirty, but it works. The idea is simple: if the onLoad method is to be executed before the proxy exists, than we wait some miliseconds and try again later until the proxy is ready to be used. So, if your method is like this:
Change it to:
This will check every 10 milliseconds if the proxy is already there. If it is, your method will be run. If not, it will keep trying.