Although this question is similar, it is not what I am looking for.
Let's say on HostA.com I include a script from HostB.com:
var hostName = window.location.hostname;
I am loading the script with RequireJS which looks something like this:
I figured out, with help from @adeneo that I can do something like this:
And I can parse it for the hostname.
var url = $('script[data-main*="/main.js"]').attr('data-main'); parser = document.createElement('a'); parser.href = url; host = parser.hostname;
Thanks for the suggestions and nudge in the right direction!
Turns out their is an easier way for anyone using RequireJS (who finds this question in search) and needs to be able to load absolute URL's with the script host:
var myCssPath = require.toUrl('css/mystyles.css');
That builds an absolute path using the hostname of the server running!