Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to add custom javascript in wordpress child theme

I have avada theme, and I created child theme, how to add my custom js file in child theme.

I tried using this video tutorial, but without success https://www.youtube.com/watch?v=4xbvhXj72kU

Can you help me!

like image 998
ml92 Avatar asked Feb 04 '26 00:02

ml92


1 Answers

Here is best way to include custom js in child theme:

function my_scripts_method() {
wp_enqueue_script(
    'custom-script',
    get_stylesheet_directory_uri() . '/js/custom_script.js',
    array( 'jquery' )
 );
}

add_action( 'wp_enqueue_scripts', 'my_scripts_method' );
like image 91
Gauravbhai Daxini Avatar answered Feb 05 '26 12:02

Gauravbhai Daxini



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!