Menu Close

Correct way to add a JavaScript in the functions.php

Add JavaScript in WordPress function file

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' ); 
Posted in WordPress

You can also read...