Title: How do I use wp_register_script() and wp_enqueue_script() functions
Last modified: August 22, 2016

---

# How do I use wp_register_script() and wp_enqueue_script() functions

 *  [Digex](https://wordpress.org/support/users/digex/)
 * (@digex)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/how-do-i-use-wp_register_script-and-wp_enqueue_script-functions/)
 * I have a plugin that uses jQuery, when activated, it breaks my template.
    The
   plugin does not work unless I comment out the following in the footer.php `<script
   src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">`</script
   >
 * When I comment this jquery out the template breaks. When it’s not commented out,
   the template is fine, but the plugin does not work.
 * This is in my functions.php
 *     ```
       add_filter( 'wp_enqueue_scripts', 'change_default_jquery', PHP_INT_MAX );
   
       function change_default_jquery( ){
           //wp_dequeue_script( 'jquery');
           //wp_deregister_script( 'jquery');
       }
       ```
   
 * The main problem is that there are two jQuery files with the same version loaded.
   I can’t find the call to jquery.js?ver1.11.1 that shows up in the header. I want
   to add script, and need to use wp_register_script() and wp_enqueue_script() functions.
 * I found a solution, but i don’t understand how it works.
 *     ```
       function wptuts_scripts_with_jquery()
       {
           // create array of all scripts
           $scripts=array('custom-script'=>'/js/custom-script.js',
                         'custom-script1'=>'/js/custom-script1.js',
                         'custom-script2'=>'/js/custom-script2.js');
           foreach($scripts as $key=>$sc)
           {
              wp_register_script( $key, get_template_directory_uri() . $sc, array('jquery') );
              wp_enqueue_script( $key );
           }
       }
       add_action( 'wp_enqueue_scripts', 'wptuts_scripts_with_jquery' );
       ```
   
 * How do I solve this problem?

Viewing 1 replies (of 1 total)

 *  Thread Starter [Digex](https://wordpress.org/support/users/digex/)
 * (@digex)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/how-do-i-use-wp_register_script-and-wp_enqueue_script-functions/#post-5885489)
 * 1. The url [http://bit.ly/1Ea2wqT](http://bit.ly/1Ea2wqT)
    This shows where the
   plugin works, but template is broken.
 * 2. The second url [http://bit.ly/1BuC3mT](http://bit.ly/1BuC3mT)
    This shows 
   where the template works, but the plugin is broken
 * The plugin is Screets X Live chat in the bottom right corner.

Viewing 1 replies (of 1 total)

The topic ‘How do I use wp_register_script() and wp_enqueue_script() functions’ 
is closed to new replies.

## Tags

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

 * 1 reply
 * 1 participant
 * Last reply from: [Digex](https://wordpress.org/support/users/digex/)
 * Last activity: [11 years, 2 months ago](https://wordpress.org/support/topic/how-do-i-use-wp_register_script-and-wp_enqueue_script-functions/#post-5885489)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
