Custom Javascript nothing happen
-
https://community.nodebb.org/topic/11608/custom-javascript
I follow this post to set the javascript on my nodebb like this
nothing happen.so I try to add to the header like this
or hard code to the footer.tpl, also get this error
then I add jquery manually before my code like this
Finally get works, but only works on the first visit, nothing happen on change page.
whats wrong is that? what should I do? Thank you.
-
Disable Cloudflare's Rocket Loader. It breaks things here because it's deferring loading of scripts.
To do that go on you Cloudflare page to Speed>Optimization and toggle Rocket Loader there.
I haven't tested it, but you can also try excluding your specific script from asynchronous loading by adding
data-cfasync="false"
attribute to the script tag, but I think the issue is with jQuery being loaded after your script so I don't think this would fix it (adding this to jQuery script tag should work, but it requires modifying the theme, I think. Or something else in NodeBB code) -
@oplik0 said in Custom Javascript nothing happen:
Disable Cloudflare's Rocket Loader. It breaks things here because it's deferring loading of scripts.
To do that go on you Cloudflare page to Speed>Optimization and toggle Rocket Loader there.
I haven't tested it, but you can also try excluding your specific script from asynchronous loading by adding
data-cfasync="false"
attribute to the script tag, but I think the issue is with jQuery being loaded after your script so I don't think this would fix it (adding this to jQuery script tag should work, but it requires modifying the theme, I think. Or something else in NodeBB code)After I turn off the Rocket Loader of Cloudflare, all script works now, thank you very much.