Executing JS on every page

Hi all,

We want to execute custom javascript on every page load within an interface.

It has a theme pack.

It must execute when navigating between sub tabs (which doesn’t cause a full page load).

Surprisingly, listening to the “popstate” event with js embedded in the header.vue or footer.vue doesn’t seem to detect this navigation.

What is the accepted technique for ensuring our custom javascript executes on every navigation?


Hi Paul,

There is already some code in the themepack header.vue that does this sort of thing, have a look at the line where it has the MutationObserver defined in there.

You can create your own MutationObserver to watch for more specific things on the page, for instance if you wanted to detect things that change the page due to dependencies etc.

1 Like

Thanks Ged!

We are using that now.

Thanks again.