1

When browsing a website is there any way to detect whether it's client-side routing or server-side routing in use, except for checking the network tab (in dev tools) for downloaded HTML documents?

Fellow Stranger
  • 32,129
  • 35
  • 168
  • 232

1 Answers1

-1

You could use the beforeunload event to decide what type of routing that is.

window.addEventListener('beforeunload', function (e) {
  console.log(e);

  // This is usually used to block user navigation, for example, when they have not saved cahnges
  /**
   * // Cancel the event
   * e.preventDefault();
   * // Chrome requires returnValue to be set
   * e.returnValue = '';
   */
});

To detect changes to DOM, you could use MutationObserver. But I would either useone or the other.

Akxe
  • 9,694
  • 3
  • 36
  • 71