I\'m trying to do something like a C #include \"filename.c\"
, or PHP include(dirname(__FILE__).\"filename.php\")
but in javascript. I know I can do
I've more recently found a much cleaner approach to this, which can be executed at any time, rather than being forced to do it synchronously when the script loads.
Use stackinfo to get a stacktrace at a current location, and grab the info.file
name off the top of the stack.
info = stackinfo()
console.log('This is the url of the script '+info[0].file)