1
2
3
4
5
6
7
8
9
10
11
12
13
<script>
  const socket = new WebSocket('ws://' + location.host + '/warm-reload');
  const cb = ev => {
    const originalLocation = window.location.href;
    setTimeout(() => {
      if (window.location === originalLocation) {
        window.location.reload();
      }
    }, 500);
  };
  socket.onerror = cb;
  socket.onclose = cb;
</script>