:+1: for explicit protocol.

> I'm a bit unsure on how you pass the port along

`location.host` contains hostname + port ([docs](https://developer.mozilla.org/en-US/docs/Web/API/Location))

Looking at the final code, it would be nice to extract the string manipulation into a function. Perhaps rename & extend `resolveRelativePath` to `getWebSockeUrl`

```js
function getWebSocketUrl() {
  var a = document.createElement('a');
  // browser will resolve this relative path to an absolute one
  a.href = 'ws';
  a.protocol = window.location.protocol === 'https:' ? 'wss:' : 'wss:';
  return a.href;
}
```

Also note that location.protocol ends with `:` (`https:`, not `https`).