Move wp_register_script to the top, in case wp_scripts does not exist yet