Menu Close

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

codeamend

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

Posted in WordPress

You can also read...

Leave a Reply

Your email address will not be published.