Best place to insert custom jquery

Thoughts?

I’ve inserted custom jquery via wp_register_script and wp_enqueue_script inside of scripts.php

Is this the best way? Also, is assest/js/custom.js the best place to store my custom .js?

Here is what my code looks like inside of Scripts.php

//CUSTOM
wp_register_script('custom', get_template_directory_uri() . '/assets/js/custom.js', false, null, true);
wp_enqueue_script('custom');

Thank you. I appreciate your time.

If you absolutely need your JS in a separate file, then this is the right place to do it… but a better method is usually to add the file to /assets/js/plugins/ and then minify it with Grunt.

If you just have a small amount of javascript to add, then add it into /assets/js/_main.js and minify that with Grunt.

1 Like

Thanks Chris! I’m getting to know Grunt a little more each day. Cheers!