If you call an external script that you want to host on your script, you might want to note that jquery based on ajax script is asynchronous by defealt.
Invoking an external script asynchronously will cause the rest of the rest to be completed before loading the external script.
Today I ran into the same problem that was easily resolved by making a small reference to a message from Sam Arul Raj:
$.ajax({ type: "GET", url: "test.js", dataType: "script", async: false });
source share