WP Plugin Running before jQuery

Your code doesn’t work because of a fundamental ordering problem.

You’re hooking into wp_footer. Then you’re registering a script and enqueueing it. Finally, you echo some code.

Here’s the problem, the act of enqueueing a script does not cause an echo of the script code immediately. Enqueueing does just what it says, it sets the script up to be added to the page output at a later time. So your echo of the script code here is too early.

Specifically, the enqueued scripts for the footer happen in the wp_print_footer_scripts call, which is connected to the wp_footer action with priority 20. So you need to enqueue before then, but print your custom script code after then.

So make a new function. Hook it to the wp_print_footer_scripts action. Then move your echo code into that, but leave the enqueue code where it is.