I wonder if it is possible to use MutationObserver to monitor change in window.location.pathname (or window.location.hash).
No - you cannot use MutationObservers
The new EcmaScript 7 (in preview, draft) is going to have Object.observe
which will allow you to monitor any object. However, that is in not going to work: observing global objects is a security risk and I doubt that any browser will allow that (Chromium issue 494574).
Also, as other pointed out, window.location is a system object (of type Location Object) so it is not covered by Object.observe
.
You can test that with Chrome 43 which already supports Object.observe: kangax.github.io/compat-table/es7/#Object.observe
So the only solution is to watch changes using timeout mechanism or use window.onpopstate
(if you need to monitor only hash).