Title: Linking child theme JavaScript file
Last modified: August 30, 2016

---

# Linking child theme JavaScript file

 *  Resolved [bguy0501](https://wordpress.org/support/users/bguy0501/)
 * (@bguy0501)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/linking-child-theme-javascript-file/)
 * How can I link a JavaScript file from my child theme using this plugin?
 * I am using the Customizr Pro theme.
 * [https://wordpress.org/plugins/child-theme-configurator/](https://wordpress.org/plugins/child-theme-configurator/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [lilaeamedia](https://wordpress.org/support/users/lilaeamedia/)
 * (@lilaeamedia)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/linking-child-theme-javascript-file/#post-6891185)
 * The best way is to add an action to your child theme functions file. It does 
   not require the plugin, but CTC makes it easy. You should deactivate the child
   theme while you are editing to prevent syntax errors from breaking your site.
 * Go to the files tab and click the link labeled “functions.php.” This will take
   you to the theme editor.
 * After you make the change, test it using the theme preview. View source in your
   browser to verify the script is being linked correctly. If you errors exist, 
   you are safe to re-activate your child theme.
 * Use the following code as a guide to link your script file.
 *     ```
       function my_custom_scripts(){
           wp_enqueue_script( 'my-script-1', get_stylesheet_directory_uri() . '/path/to/script', array( 'jquery' ) );
       }
       add_action( 'wp_enqueue_scripts', 'my_custom_scripts' );
       ```
   
 * The actual name of the function is up to you as long as it is unique.
 * The first argument of the wp_enqueue_script function is a “handle” that WordPress
   uses to identify the script in the script queue. It can be any unique string.
 * The second argument is the path to the script file. If your javascript file is
   not located in your child theme, you can use an absolute path instead of the 
   function in the example, such as `'http://www.somedomain.com/path/to/script.js'`
 * The third argument contains a array of prerequisite script handles (scripts that
   must load before the script being queued ). In this example we are requiring 
   the jquery library.
 * For more information, see:
 * [http://codex.wordpress.org/Plugin_API](http://codex.wordpress.org/Plugin_API)
   
   [https://codex.wordpress.org/Function_Reference/wp_enqueue_script](https://codex.wordpress.org/Function_Reference/wp_enqueue_script)
   [http://codex.wordpress.org/Child_Themes](http://codex.wordpress.org/Child_Themes)
   [http://codex.wordpress.org/Template_Hierarchy](http://codex.wordpress.org/Template_Hierarchy)
   [http://www.childthemeconfigurator.com/how-to-use/](http://www.childthemeconfigurator.com/how-to-use/)
   [http://www.childthemeconfigurator.com/tutorial-videos/](http://www.childthemeconfigurator.com/tutorial-videos/)
   [http://www.childthemeconfigurator.com/how-child-themes-work/](http://www.childthemeconfigurator.com/how-child-themes-work/)
 * Hopefully this will get you started.
 *  Thread Starter [bguy0501](https://wordpress.org/support/users/bguy0501/)
 * (@bguy0501)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/linking-child-theme-javascript-file/#post-6891337)
 * Thanks so much for the info! I will give that a try.
 *  Thread Starter [bguy0501](https://wordpress.org/support/users/bguy0501/)
 * (@bguy0501)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/linking-child-theme-javascript-file/#post-6891376)
 * I replaced the ‘/path/to/script’ with ‘/script.js’ because my js file is in the
   same folder as my css file. When I view the source I can find both files being
   linked, but my script still does not work. I couldn’t find anything in the links
   you provided that jumped out as a possible cause. Is there anything you can think
   of that I may have missed?
 * Thanks for the help!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Linking child theme JavaScript file’ is closed to new replies.

 * ![](https://ps.w.org/child-theme-configurator/assets/icon-128x128.png?rev=1557885)
 * [Child Theme Configurator](https://wordpress.org/plugins/child-theme-configurator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/child-theme-configurator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/child-theme-configurator/)
 * [Active Topics](https://wordpress.org/support/plugin/child-theme-configurator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/child-theme-configurator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/child-theme-configurator/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [bguy0501](https://wordpress.org/support/users/bguy0501/)
 * Last activity: [10 years, 4 months ago](https://wordpress.org/support/topic/linking-child-theme-javascript-file/#post-6891376)
 * Status: resolved