Title: wp_enqueue_script()
Last modified: August 21, 2016

---

# wp_enqueue_script()

 *  Resolved [sheva29](https://wordpress.org/support/users/sheva29/)
 * (@sheva29)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/wp_enqueue_script-3/)
 * Hello,
 * I am trying to load two scripts using wp_enqueue_script(). Unfortunately only
   the first one loads but not the second one. Here is the code:
 *     ```
       //Load my own jQuery
       function fix_noconflict() {
       wp_deregister_script( 'jquery' );
       wp_register_script( 'jquery' , 'http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js' );}
   
       add_action( 'wp_enqueue_scripts' , 'fix_noconflict' );
   
       //This two functions follow the same
       function mauricio_bootstrap_script_jquery() {
   
       //Includes bootstrap jQuery
       wp_register_script( 'custom-script', get_template_directory_uri().'/mauricio_bootstrap/js/bootstrap.js', array( 'jquery' ) );
   
       //This enqueus  the script
   
       wp_enqueue_script( 'custom-script' );
       }
       // Adds the new bootstrap function to the wp_enqueue_scripts
        add_action( 'wp_enqueue_scripts', 'mauricio_bootstrap_script_jquery' );
   
       function mauricio_bootstrap_script_carousel() {
   
       wp_register_script( 'myscript', get_template_directory_uri().'/mauricio_bootstrap/js/bootstrap-carousel.js', array( 'jquery' ) );
   
       wp_enqueue_script( 'myscript' );
       }
   
       add_action( 'wp_enqueue_script', 'mauricio_bootstrap_script_carousel' );
       ```
   
 * Any suggestion will be more than welcome.
 * Thanks,
 * M

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

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/wp_enqueue_script-3/#post-3853651)
 * Stop de-registering core jQuery. There is absolutely no need to do that.
 *  Thread Starter [sheva29](https://wordpress.org/support/users/sheva29/)
 * (@sheva29)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/wp_enqueue_script-3/#post-3853665)
 * Thanks esmi.
 * I did it because I want to load the one from the snippets. I read that it causes
   less trouble. But that still does not solve my problem with the last function.
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/wp_enqueue_script-3/#post-3853667)
 * > I want to load the one from the snippets
 * why?
 *  Thread Starter [sheva29](https://wordpress.org/support/users/sheva29/)
 * (@sheva29)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/wp_enqueue_script-3/#post-3853670)
 * As I said I heard that it causes less conflicts when loading scripts of your 
   own.
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/wp_enqueue_script-3/#post-3853722)
 * De-registering core jQuery will create a _boatload_ of issues in WordPress. What
   happens if you re-write your code without de-registering jQuery?
 *  Thread Starter [sheva29](https://wordpress.org/support/users/sheva29/)
 * (@sheva29)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/wp_enqueue_script-3/#post-3853725)
 * I did, but the boostrap-carousel.js still does not load :(. Only bootstrap.js
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/wp_enqueue_script-3/#post-3853729)
 * What code are you using now?
 *  Thread Starter [sheva29](https://wordpress.org/support/users/sheva29/)
 * (@sheva29)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/wp_enqueue_script-3/#post-3853730)
 * This:
 *     ```
       //This two functions follow the same
       function mauricio_bootstrap_script_jquery() {
   
       //Includes bootstrap jQuery
       wp_register_script( 'custom-script', get_template_directory_uri().'/mauricio_bootstrap/js/bootstrap.js', array( 'jquery' ) );
   
       //This enqueus  the script
   
       wp_enqueue_script( 'custom-script' );
       }
       // Adds the new bootstrap function to the wp_enqueue_scripts
        add_action( 'wp_enqueue_scripts', 'mauricio_bootstrap_script_jquery' );
   
       function mauricio_bootstrap_script_carousel() {
   
       wp_register_script( 'myscript', get_template_directory_uri().'/mauricio_bootstrap/js/bootstrap-carousel.js', array( 'jquery' ) );
   
       wp_enqueue_script( 'myscript' );
       }
   
       add_action( 'wp_enqueue_script', 'mauricio_bootstrap_script_carousel' );
       ```
   
 * I completely got rid of the first function
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/wp_enqueue_script-3/#post-3853734)
 * Try:
 *     ```
       function mauricio_bootstrap_scripts() {
       	wp_register_script( 'custom-script', get_template_directory_uri().'/mauricio_bootstrap/js/bootstrap.js', array( 'jquery' ) );
       	wp_enqueue_script( 'custom-script' );
   
       	wp_register_script( 'myscript', get_template_directory_uri().'/mauricio_bootstrap/js/bootstrap-carousel.js', array( 'jquery' ) );
       	wp_enqueue_script( 'myscript' );
       }
       add_action( 'template_redirect', 'mauricio_bootstrap_scriptsl' );
       ```
   
 *  Thread Starter [sheva29](https://wordpress.org/support/users/sheva29/)
 * (@sheva29)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/wp_enqueue_script-3/#post-3853738)
 * It worked! Thanks so much!
 * Could you ellaborate on the $tag ‘template_redirect’. So if in the future I want
   to use two separete functions. I use ‘template_redirect’ instead of ‘wp_enqueue_script’.
   I noticed in the API section for plugins that there are a bunch of them.
 * Best,
 * Mauricio
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/wp_enqueue_script-3/#post-3853799)
 * > Could you ellaborate on the $tag ‘template_redirect’.
 * It’s an action hook. See [http://codex.wordpress.org/Plugin_API/Action_Reference/template_redirect](http://codex.wordpress.org/Plugin_API/Action_Reference/template_redirect)
   and [http://codex.wordpress.org/Plugin_API/Action_Reference](http://codex.wordpress.org/Plugin_API/Action_Reference)

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

The topic ‘wp_enqueue_script()’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 11 replies
 * 2 participants
 * Last reply from: [esmi](https://wordpress.org/support/users/esmi/)
 * Last activity: [12 years, 9 months ago](https://wordpress.org/support/topic/wp_enqueue_script-3/#post-3853799)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
