# beforePageChange plugin API?

**URL:** https://meta.discourse.org/t/beforepagechange-plugin-api/212246
**Category:** Development
**Created:** [December 15, 2021, 9:12pm UTC](https://meta.discourse.org/t/beforepagechange-plugin-api/212246 "2021-12-15T21:12:49Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![Johani](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/johani/32/176920_2.png) [@Johani](https://meta.discourse.org/u/Johani)
#### Post date: [December 15, 2021, 9:26pm UTC](https://meta.discourse.org/t/beforepagechange-plugin-api/212246/2 "2021-12-15T21:26:58Z")

</div>

Have a look here

[Trigger javascript on clicking any page link, but before the page content loads? - #2 by Johani](https://meta.discourse.org/t/trigger-javascript-on-clicking-any-page-link-but-before-the-page-content-loads/167970/2)

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.

---

_[View the full topic](https://meta.discourse.org/t/beforepagechange-plugin-api/212246)._
