I have a JavaScript file, which needs to know from which location it is loaded. My requirement is similar to How may I reference the script tag that loaded the currently-executing script?
I am using
document.currentScript;
to get the script path. But this implementation is breaking if my JavaScript file is loaded using jQuery's getScript() Method:
$(document).ready(function(){
$("button").click(function(){
$.getScript("my_script.js");
});
});
When I do this, document.currentScript always returns null. Is there a work around to fix this issue?