This is a bit of an odd question, I have implemented Barba.js (a PJAX plugin for handling seamless page transitions) on a WordPress site. Use of the plugin requires re-initialisation of scripts between pages. I have this working correctly except for when a WordPress plugin is concerned.
When a page loads in directly (i.e via explicit URL or hard refresh, the plugin renders content correctly, however if I navigate away and back to the page via the menu inside Barba the plugin doesn’t re-initialise. Please see the below explanation:
example.com/page1 (contains plugin generated content which loads correctly)
navigate to new page via website menu inside Barba container
example.com/page2 (loads seamlessly and other custom animations work as expected)
navigate back to the first page via website menu inside Barba container
When I arrive at example.com/page1 again the plugin content does not render at all. I believe this is because scripts are not being re-initialised.
I’ve read that WordPress uses WP_ENQUEUE_SCRIPT and WP_ENQUEUE_STYLE to initialise plugin scipts and styles, but this is PHP, which is not my forte and as far as I know I can’t hook into this?
Ideally, I need to be able to reinit the plugin(s) like this so that it remains in context to other custom jS animations:
function reinitWPPlugin() {
//do re-initialisation here
}
Can anyone point me in the right direction to reinit WordPress plugins?



