Refactored loadScript to check where it is hosted to get the path to the other .js files