title: Fastest way to grab domain/host name using javascript
body: <p>I already have quite a bit of js on my site, so I want to have a function that grabs the domain name of the current url as efficiently as possible. </p>
  
  <p>Example:</p>
  
  <p>input : <a href="https://stackoverflow.com/questions/ask">https://stackoverflow.com/questions/ask</a></p>
  
  <p>result : stackoverflow.com</p>
  
  <p>input : <a href="http://test.stackoverflow.com/questions/ask" rel="nofollow noreferrer">http://test.stackoverflow.com/questions/ask</a></p>
  
  <p>result : test.stackoverflow.com</p>
  
  <p>I guess the best way to start is with document.location, but I'm at odds what to do from there. </p>