How do I know if I should enqueue JS code or just include it in ONE PHP function?
Best practice in this case would be to enqueue the js file inside the WP functions.php file. Are the braintree submit pages on their own unique templates? If so you could add something like this to your functions file: function register_scripts() { if(is_page_template(‘template-parts/page-braintree.php’)): wp_register_script( ‘braintree-js’, get_template_directory_uri() . ‘/js/braintree.js’, array( ‘jquery’ ), false, true ); wp_enqueue_script( … Read more