Search
Close this search box.

Use WP Enqueue Script To Properly Add Javascript Files To WordPress

[updated_on]
Share this post:

Paste the code below into your functions.php file.

Then, replace PATH TO JS FILE with the absolute or relative URL to the Javascript or jQuery file you want to include.

function enqueue_my_custom_script() {
    wp_enqueue_script( 'my-custom-js', 'PATH TO JS FILE', false );
}

add_action( 'wp_enqueue_scripts', 'enqueue_my_custom_script' );
Share this post:

Leave a Comment

Your email address will not be published. Required fields are marked *

WPLearningLab