Adding JavaScript or jQuery files to your Moodle theme is a relatively simple process.
In fact, Moodle provides a simple way to make the process particularly clean and easy-going on your maintenance and development workflow.
In your Moodle theme directory, first create a folder named 'javascript'.
All your JavaScript and jQuery files should reside within the YOUR_THEME_NAME/javascript directory.