Title: Javascript loading with dependency
Last modified: September 1, 2016

---

# Javascript loading with dependency

 *  Resolved [mames40](https://wordpress.org/support/users/mames40/)
 * (@mames40)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/javascript-loading-with-dependency/)
 * Hi,
    I’m trying to get this code working (`http://http://jsfiddle.net/qlmhuge/
   t7a1sh4u/`)on my wordpress site (`http://dev-markandersonpianist.pantheonsite.
   io/discography/`).
 * I have created a function in my functions.php file to load the scripts.
 *     ```
       function my_scripts_method() {
         $template_dir = get_stylesheet_directory_uri();
         wp_enqueue_script('results', $template_dir . '/js/results.js', array('jquery'), null, true);
         wp_enqueue_script('discography', $template_dir . '/js/discography.js', array('jquery', 'results'), null, true);
       }
       add_action( 'wp_enqueue_scripts', 'my_scripts_method');
       ```
   
 * Have I created the correct wp_enqueue_script to load the dependency that the 
   first script has on the second script. See (`http://http://jsfiddle.net/qlmhuge/
   t7a1sh4u/`) scripts.
 * I have included the scripts on the discography page as well.
 * The scripts don’t appear to be loading. Any help would be much appreciated.

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

 *  Anonymous User 14885823
 * (@anonymized-14885823)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/javascript-loading-with-dependency/#post-7468375)
 * Hello!
    Are your JavaScript files located in a “js” folder inside your theme 
   folder?
 * I see your main CSS file is at ([http://dev-markandersonpianist.pantheonsite.io/wp-content/themes/marksteinway/style.css](http://dev-markandersonpianist.pantheonsite.io/wp-content/themes/marksteinway/style.css)),
   but when I request ([http://dev-markandersonpianist.pantheonsite.io/wp-content/themes/marksteinway/js/results.js](http://dev-markandersonpianist.pantheonsite.io/wp-content/themes/marksteinway/js/results.js))
   or discography.js, nothing is found… Maybe double check the paths?
 * Also, could use “[get_template_directory_uri ()](https://developer.wordpress.org/reference/functions/get_template_directory_uri/)”
   to get the template directory instead.
 * Good luck!
    -kel
 *  Thread Starter [mames40](https://wordpress.org/support/users/mames40/)
 * (@mames40)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/javascript-loading-with-dependency/#post-7468379)
 * Hi Kel,
    markandersonpianist.com uses the theme markandersonpianist not marksteinway.
   The files are located in the js folder inside the theme markandersonpianist. 
   Any other suggestions? I’m really stumped. Thanks for your help.
 *  Anonymous User 14885823
 * (@anonymized-14885823)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/javascript-loading-with-dependency/#post-7468380)
 * Hmmm, are you sure you have the correct theme activated right now?
 * If you right click–>”view source” on your page, you can see that your style.css
   file is coming from wp-content/themes/marksteinway/style.css
 * -kel
 *  Thread Starter [mames40](https://wordpress.org/support/users/mames40/)
 * (@mames40)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/javascript-loading-with-dependency/#post-7468383)
 * Interesting. This is an old site that I am updating. It’s not mine. Is it possible
   to have two themes being used? I have been making changes to the homepage and
   sidebar by placing files in markandersonpianist and it has been updating the 
   site.
 *  Thread Starter [mames40](https://wordpress.org/support/users/mames40/)
 * (@mames40)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/javascript-loading-with-dependency/#post-7468384)
 * Yes marksteinway is what is activated. I did a database import from the live 
   site so that is how it was configured but most of the files that are being used
   on in markandersonpianist like the home page box and the sidebar. I’ll move the
   javascript to marksteinway and see if that works. Thanks,
 *  Thread Starter [mames40](https://wordpress.org/support/users/mames40/)
 * (@mames40)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/javascript-loading-with-dependency/#post-7468386)
 * I moved the files to marksteinway and am getting
 *     ```
       /*! jQuery Migrate v1.4.0 | (c) jQuery Foundation and other contributors | jquery.org/license */
       "undefined"==typeof jQuery.migrateMute&&
       ```
   
 * How do I get jquery to load successfully?

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

The topic ‘Javascript loading with dependency’ is closed to new replies.

## Tags

 * [javascript](https://wordpress.org/support/topic-tag/javascript/)
 * [wp_enqueue_script](https://wordpress.org/support/topic-tag/wp_enqueue_script/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 2 participants
 * Last reply from: [mames40](https://wordpress.org/support/users/mames40/)
 * Last activity: [9 years, 11 months ago](https://wordpress.org/support/topic/javascript-loading-with-dependency/#post-7468386)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
