What is my script src URL?
Put this in the js file that needs to know it’s own url. Fully Qualified (eg http://www.example.com/js/main.js): var scriptSource = (function(scripts) { var scripts = document.getElementsByTagName(‘script’), script = scripts[scripts.length – 1]; if (script.getAttribute.length !== undefined) { return script.src } return script.getAttribute(‘src’, -1) }()); Or As it appears in source (eg /js/main.js): var scriptSource = (function() … Read more