Many programming languages provide a magic __FILE__ variable which holds the path to the currently executing file. JavaScript unfortunately don’t. Using several sources, I implemented a __FILE__ variable for JavaScript. Unfortunately it does not work in all browsers, especially not in Internet Explorer and Safari. There seems to be a possibility for IE10, but lacking a Windows 8 machine I can’t test it. If you find a way for these browsers or other improvements please contribute your code.
Here’s the source code: https://gist.github.com/3891980
Sources I used for this GIST: