beforePageChange plugin API?

Is there a plugin-API for before a new page is loaded / while a page is loading?

I have a problem where I’m changing styles on the navbar depending on the page by using the onPageChange API. Unfortunately this means that when someone is navigating around my site, the navbar changes are not taking place until the new page is loaded. So going from a page where I have a transparent navbar to a page where I have a solid one, the transparent navbar is visible until the new page has completed loading (i.e. while the spinner is present). This is a bad look so I’m looking for a solution.

Any suggestions would be greatly appreciated. Thank you!

Have a look here

Trigger javascript on clicking any page link, but before the page content loads? - #2 by Johani

Generally, though, onPageChange should be avoided if you can. There’s other ways to check the current route and do some conditional work based on that. Happy to take a look if you post your code and desired result here.

1 Like