The correct way to add a JavaScript in the functions.php

Posted in WordPress
Tagged add javascript in wordpress, The correct way to add a JavaScript in the functions.php, wp_enqueue_scripts, wp_register_script
Let’s see how to Add javacscript file in function.php file.
Code
function my_scripts() {
wp_register_script( 'custom-script', get_template_directory_uri() . '/jquery.js' );
wp_enqueue_script( 'custom-script' );
}
add_action( 'wp_enqueue_scripts', 'my_scripts' );
Share