Title: Theme Development, Adding Multiple JS which is dependant upon Jquery
Last modified: August 20, 2016

---

# Theme Development, Adding Multiple JS which is dependant upon Jquery

 *  [Matt Lane](https://wordpress.org/support/users/mattlane/)
 * (@mattlane)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/theme-development-adding-multiple-js-which-is-dependant-upon-jquery/)
 * Hopefully this is a fairly simple query, I’m figuring out how to add JS to my
   theme and wanted to be certain I was doing this in the correct method, I’ve followed
   as best i can tutorials and the codex. At this time what i have coded in is working,
   but being new to wordpress I’m sure you can understand i want to be certain I’m
   doing this right and not just ‘making it work’.
 * So I’m adding in three scripts (uniform.js, hoverIntent.js and superfish.js –
   I abbreviated the names for ease). So this is the code i have in my functions
   file to handle the loading:
 *     ```
       function loadAlljs() {
       	wp_enqueue_script(
       		'uniform',
       		get_template_directory_uri() . '/js/jquery.uniform.min.js',
       		array('jquery')
       	);
       		wp_enqueue_script(
       		'hoverIntent',
       		get_template_directory_uri() . '/js/hoverIntent.js',
       		array('jquery')
       	);
       	wp_enqueue_script(
       		'superfish',
       		get_template_directory_uri() . '/js/superfish.js',
       		array('jquery')
       	);
       }
   
       add_action('wp_enqueue_scripts', 'loadAlljs');
       ```
   
 * So firstly is the above correct or am i doubling up on code that isn’t required?
 * My next point which does link through to this is that with these scripts to allow
   them to have effect on the page i have to include some jquery in the <head>.
 *     ```
       <script type="text/javascript">
       		// initialise plugins
       		jQuery(function(){
       			jQuery('ul.sf-menu').superfish();
       		});
       </script>
       ```
   
 * Above is what i need to add to enable super fish menus, at present I am just 
   using a regular old php require_once to include the code AFTER the call to wp_head().
 * Now as i’ve said all is working so this is more a check to see if I am doing 
   this in the correct way, or most efficient way.
 * Thanks in advance.
 * Matt

The topic ‘Theme Development, Adding Multiple JS which is dependant upon Jquery’
is closed to new replies.

## Tags

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

 * 0 replies
 * 1 participant
 * Last reply from: [Matt Lane](https://wordpress.org/support/users/mattlane/)
 * Last activity: [14 years, 2 months ago](https://wordpress.org/support/topic/theme-development-adding-multiple-js-which-is-dependant-upon-jquery/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
