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
    alt text
    nothing happen.

    so I try to add to the header like this
    alt text
    or hard code to the footer.tpl, also get this error
    alt text

    then I add jquery manually before my code like this
    alt text
    Finally get works, but only works on the first visit, nothing happen on change page.
    alt text

    whats wrong is that? what should I do? Thank you.

  • Admin Staff

    I tested your first example on this forum and it works fine.

  • Plugin & Theme Dev Community Rep

    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.

Log in to reply
 

Suggested Topics

  • 11
  • 2
  • 7
  • 3
  • 6
| |