When I tested this myself I found it only really needed a sleep(2) before the script was ready. I'm sure there must be a way we can work it, for example waiting for a HTMLElement and if that is not present then triggering the script. Then we can be confident the script will have been loaded.