That's because the JavaScript present in script.js are called after Jquery.
Just for knowledge. If you want to add inline JavaScript with Jquery function, you should start it after the instantiation of Jquery.
You can do that after the load event (similar to defer) For instance.
JQuery(window).on("load", function() {
console.log("My Jquery code");
});
I'm not sure if this form will work with the JQuery of dokuwiki.
Check this article where you can see most of them.
https://datacadamia.com/web/dom/loaded#jquery