title: Detect an URL change in a SPA
body: <p>I would like to listen to path changes in a SPA which is not maintained by me.</p>
  <p>I found one solution here: <a href="https://stackoverflow.com/a/44819548/7042552">https://stackoverflow.com/a/44819548/7042552</a></p>
  <p>But still, it seems kind of &quot;hacky&quot; to me - but still my implementation is like this:</p>
  <pre><code>let url = window.location.href;
  
  ['click','popstate', 'onload'].forEach( evt =&gt;
          window.addEventListener(evt, function () {
              requestAnimationFrame(()=&gt;{
                  if (url !== location.href) {
                      // do stuff
                  }
                  url = location.href;
              });
          }, true)
      );
  </code></pre>
  <p>Is there a better or more generic way to listen for page loads in a SPA?</p>