How can I make sure my JS script gets executed first, among other scripts?

First of all, if you are not using jQuery, then do not pass the jQuery as a dependency to the wp_enqueue_script() function.

Now, about your question. It’s not really WordPress related, but anyway. You didn’t mention how you call this function, since that’s all that matters here. If you output your code lately, such as in the footer, it won’t run until everything before that part is loaded. My suggestion is, to use a child them and add the code directly after your menu is output, and call the function. This way, the script will run immediately after the menu is created, and since no jQuery is required, you won’t have a problem using it.

error code: 523