I want to have a check in my javascript if the page loading up is on my local machine.
The reason why I want to do that is that when I developing I like to make sure
The location.hostname variable gives you the current host. That should be enough for you to determine which environment you are in.
location.hostname
if (location.hostname === "localhost" || location.hostname === "127.0.0.1") alert("It's a local server!");