Get domain of Javascript file

So I have a site at and I have a Javascript file on a CDN, the Javascript file could be at or, I need to get the value of the hostname the javascript file is on. Is there any way to do this? I cannot modify the embed code of the javascript file to add a custom ID or add an additional variable on

The reasons why I need this are far too complicated for one post =)



You can get all the scripts you are loading in your page and search by name for the right one

Here is your example


If you know the index of the embedded <script> inside document.getElementsByTagName('script') you may read the src-attribute of the <script> and extract the hostname from that src.


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.