Title: Adding jQuery without breaking stuff
Last modified: August 21, 2016

---

# Adding jQuery without breaking stuff

 *  Resolved [tkse](https://wordpress.org/support/users/tkse/)
 * (@tkse)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/adding-jquery-without-breaking-stuff/)
 * Hi.
 * I’m having trouble adding jQuery to my website without breaking other scripts
   like the dropdown when logged in and plugins that also uses jQuery.
 * Currently I have linked jQuery for my theme in functions.php like this:
 *     ```
       /* 	Load jQuery for own script	*/
       function my_init() {
       	if (!is_admin()) {
       		wp_deregister_script('jquery');
       		wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js', false, '1.3.2', true);
       		wp_enqueue_script('jquery');
   
       		// load a JS file from my theme: js/theme.js
       		wp_enqueue_script('my_script', '/wp-content/themes/rksgolf/js/theme.js', array('jquery'), '1.0', true);
       	}
       }
       add_action('init', 'my_init');
       ```
   
 * This works fine for my scripts, but breaks others. How can I have mine co-exist
   with others?

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

 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [12 years, 1 month ago](https://wordpress.org/support/topic/adding-jquery-without-breaking-stuff/#post-4776742)
 * What JavaScript errors are you getting? Deregistering jQuery is a big thing you
   know.
 *  Thread Starter [tkse](https://wordpress.org/support/users/tkse/)
 * (@tkse)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/adding-jquery-without-breaking-stuff/#post-4776747)
 * You can have a look: [http://rksgolf.no](http://rksgolf.no)
 * Currently, my own script is running the slider in the sidebar, while at the bottom
   of the page I have another slider run by a plugin, which doesn’t show up as long
   as I link jQuery in the functions.php file. Same thing with the adminbars dropdown
   menu.
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [12 years, 1 month ago](https://wordpress.org/support/topic/adding-jquery-without-breaking-stuff/#post-4776750)
 * I would just use the version of jQuery that pretty much all themes, plugins and
   the core application rely on.
 *  Thread Starter [tkse](https://wordpress.org/support/users/tkse/)
 * (@tkse)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/adding-jquery-without-breaking-stuff/#post-4776759)
 * Example code?
 * I changed the code to:
 *     ```
       if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue", 11);
       function my_jquery_enqueue() {
          wp_deregister_script('jquery');
          wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js", false, null);
          wp_enqueue_script('jquery');
       }
       ```
   
 * Ignoring my own .js file in functions.php and called the script within sidebar.
   php instead. Works for now at least.
 *  [robbieobbie](https://wordpress.org/support/users/robbieobbie/)
 * (@robbieobbie)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/adding-jquery-without-breaking-stuff/#post-4776769)
 * Andrew is right, deregistering the current WordPress version of JQuery is never
   good practice if you are relying on the use of plugins. Plugin authors work hard
   to keep their plugins up to date with the most recent versions of WordPress and
   this might be their biggest pet peeve as outdated versions of JQuery easily break
   them.
 *  Thread Starter [tkse](https://wordpress.org/support/users/tkse/)
 * (@tkse)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/adding-jquery-without-breaking-stuff/#post-4776774)
 * So how should I go about adding custom jQuery?
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [12 years, 1 month ago](https://wordpress.org/support/topic/adding-jquery-without-breaking-stuff/#post-4776786)
 * I don’t understand, why do you have to use your own jQuery **library**?
 *  Thread Starter [tkse](https://wordpress.org/support/users/tkse/)
 * (@tkse)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/adding-jquery-without-breaking-stuff/#post-4776789)
 * Don’t I? I guess I’ve looked it up at some point, read about the enqueue_script
   and always assumed you had to.
 * Can I just delete the above code from functions.php and my script should still
   work?
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [12 years, 1 month ago](https://wordpress.org/support/topic/adding-jquery-without-breaking-stuff/#post-4776790)
 * Can you do this instead:
 *     ```
       /* 	Load jQuery for own script	*/
       function my_init() {
       	if (!is_admin()) {
       		// load a JS file from my theme: js/theme.js
       		wp_enqueue_script('my_script', '/wp-content/themes/rksgolf/js/theme.js', array('jquery'), '1.0', true);
       	}
       }
       add_action('init', 'my_init');
       ```
   
 *  Thread Starter [tkse](https://wordpress.org/support/users/tkse/)
 * (@tkse)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/adding-jquery-without-breaking-stuff/#post-4776792)
 * Excellent. Thanks! 🙂

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

The topic ‘Adding jQuery without breaking stuff’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 10 replies
 * 3 participants
 * Last reply from: [tkse](https://wordpress.org/support/users/tkse/)
 * Last activity: [12 years, 1 month ago](https://wordpress.org/support/topic/adding-jquery-without-breaking-stuff/#post-4776792)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
