'Having trouble using Barba.js and separate JS files
I've setup Barba.js on my Wordpress website. It seems to be working. the only thing is that when I transition to other pages, my other JS files don't load until a hard refresh.
I think to solve this, I have to use namespace and BeforeEnter and re-run my separate JS file within that
The only problem is I don't know how to do that. I've looked all over the net.
I've tried this (which I know is not right, but maybe on the right track?)
let script = document.createElement('script');
script.src="/flickity.init.js";
next.container.appendChild(script);
Any help would be appreciated :)
Thanks in advance!
Solution 1:[1]
Was actually a pretty simple fix.
I just wrapped my other JS files code in a const runScripts = function () {} then called the function runScripts() inside a view in my custom Barba script with beforeEnter({ next }) {} and a relevant name space.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ddizzle |
