Title: How to use enqueue_script (correctly) with multiple dependents
Last modified: August 20, 2016

---

# How to use enqueue_script (correctly) with multiple dependents

 *  [B1gJ4k3](https://wordpress.org/support/users/b1gj4k3/)
 * (@b1gj4k3)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/how-to-use-enqueue_script/)
 * Could someone please explain to me how wp_enqueue_scripts work and the proper
   way to include multiple external JavaScripts in my theme (or point me to a good
   tutorial)?
 * I haven’t been able to make sense of the WordPress codex documentation. I have
   something I’ve been using that seems to be working, but it seems rather redundant
   and not the most efficient way to do things. Here’s what I’ve got:
 *     ```
       <?php
       		function load_scripts() {
       		   wp_register_script('jshowoff', get_template_directory_uri() . '/js/jquery.jshowoff.min.js', 'jquery' );
       		   wp_register_script('bp-scripts', get_template_directory_uri() . '/js/bp-scripts.js', 'jquery' );
       		   wp_register_script('custom-forms', get_template_directory_uri() . '/js/custom-form-elements.js', 'jquery' );
       		   wp_enqueue_script('jquery');
       		   wp_enqueue_script('jshowoff');
       		   wp_enqueue_script('bp-scripts');
       		   wp_enqueue_script('custom-forms');
       		}
       		add_action('wp_enqueue_scripts', 'load_scripts');
       	?>
       ```
   
 * How can I improve this code so I can include multiple external JavaScript files
   and have them fire when jQuery is loaded?
 * Any suggestions? Thanks!

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

 *  Moderator [t-p](https://wordpress.org/support/users/t-p/)
 * (@t-p)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/how-to-use-enqueue_script/#post-2671275)
 * codex: [http://codex.wordpress.org/Function_Reference/wp_enqueue_script](http://codex.wordpress.org/Function_Reference/wp_enqueue_script)
 *  Thread Starter [B1gJ4k3](https://wordpress.org/support/users/b1gj4k3/)
 * (@b1gj4k3)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/how-to-use-enqueue_script/#post-2671290)
 * Yes. As I’ve said, I looked through that. And that’s how I arrived at the code
   I’m currently using. It doesn’t really provide a good example for multiple scripts
   that depend on the same one…

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

The topic ‘How to use enqueue_script (correctly) with multiple dependents’ is closed
to new replies.

## Tags

 * [external](https://wordpress.org/support/topic-tag/external/)
 * [javascript](https://wordpress.org/support/topic-tag/javascript/)
 * [jquery](https://wordpress.org/support/topic-tag/jquery/)
 * [js](https://wordpress.org/support/topic-tag/js/)
 * [load](https://wordpress.org/support/topic-tag/load/)
 * [multiple](https://wordpress.org/support/topic-tag/multiple/)
 * [wp_enqueue_script](https://wordpress.org/support/topic-tag/wp_enqueue_script/)

 * 2 replies
 * 2 participants
 * Last reply from: [B1gJ4k3](https://wordpress.org/support/users/b1gj4k3/)
 * Last activity: [14 years, 1 month ago](https://wordpress.org/support/topic/how-to-use-enqueue_script/#post-2671290)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
