Title: Loading jQuery
Last modified: August 24, 2016

---

# Loading jQuery

 *  [c-m](https://wordpress.org/support/users/c-m/)
 * (@c-m)
 * [11 years ago](https://wordpress.org/support/topic/loading-jquery/)
 * How do I make wordpress use the latest version available to it rather than version
   1.11 which it seems to load to by default.
 * Surely WordPress 4.2.1 should be using version 2.x by now.
 * I don’t just want tell it to get jquery from google servers as it’s important
   that it’s loaded in no-conflict mode.
 * Thanks in advance

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

 *  [Craig Ralston](https://wordpress.org/support/users/craig-ralston/)
 * (@craig-ralston)
 * [11 years ago](https://wordpress.org/support/topic/loading-jquery/#post-6099609)
 * I would not recommend deregistering core jQuery as it can cause all sorts of 
   problems. But you certainly CAN if you wish.
 * WordPress loads the jQuery version that it has been tested and shipped with. 
   If you want to use a different version, you can simply [deregister](https://codex.wordpress.org/Function_Reference/wp_deregister_script)
   core jQuery and [enqueue](https://codex.wordpress.org/Function_Reference/wp_enqueue_script)
   your own.
 *  Thread Starter [c-m](https://wordpress.org/support/users/c-m/)
 * (@c-m)
 * [11 years ago](https://wordpress.org/support/topic/loading-jquery/#post-6099626)
 * ah so wordpress 4.2.1 is only tested with jquery 1 which is old. But my code 
   below won’t work unless I add jquery 2 to the head of my theme.
 *     ```
       $(document).ready(function () {
   
           $(window).scroll(function () {
               if ($(this).scrollTop() > 500) {
                   $('.scrollup').fadeIn();
               } else {
                   $('.scrollup').fadeOut();
               }
           });
   
           $('.scrollup').click(function () {
               $("html, body").animate({
                   scrollTop: 0
               }, 900);
               return false;
           });
   
       });
       ```
   
 * If de-registering jquery 1 is so bad, what are people to do?
 *  [Craig Ralston](https://wordpress.org/support/users/craig-ralston/)
 * (@craig-ralston)
 * [11 years ago](https://wordpress.org/support/topic/loading-jquery/#post-6099640)
 * Can you try this and let me know if it works for you?
 *     ```
       jQuery(document).ready(function($) {
   
           $(window).scroll(function () {
               if ($(this).scrollTop() > 500) {
                   $('.scrollup').fadeIn();
               } else {
                   $('.scrollup').fadeOut();
               }
           });
   
           $('.scrollup').click(function () {
               $("html, body").animate({
                   scrollTop: 0
               }, 900);
               return false;
           });
   
       });
       ```
   
 *  Thread Starter [c-m](https://wordpress.org/support/users/c-m/)
 * (@c-m)
 * [11 years ago](https://wordpress.org/support/topic/loading-jquery/#post-6099657)
 * I posted the wrong script.
 * I think it’s the defer script that doesn’t work.
 *     ```
       <script type="text/javascript">
       function downloadJSAtOnload() {
       var element = document.createElement("script");
       element.src = "<?php bloginfo('template_directory'); ?>/js/misc1.js";
       document.body.appendChild(element);
       }
       if (window.addEventListener)
       window.addEventListener("load", downloadJSAtOnload, false);
       else if (window.attachEvent)
       window.attachEvent("onload", downloadJSAtOnload);
       else window.onload = downloadJSAtOnload;
       </script>
       ```
   
 * I use this to defer loading misc.js that contains all of my custom js.
 *  [Dave McHale](https://wordpress.org/support/users/dmchale/)
 * (@dmchale)
 * [11 years ago](https://wordpress.org/support/topic/loading-jquery/#post-6099672)
 * You should really be using the jQuery ready() function to check for DOM load.
   This StackOverflow link looks to be doing exactly what you’re trying to do, which
   is load a js file only once the page has otherwise loaded.
 * [http://stackoverflow.com/questions/2829483/loading-javascript-file-after-jquery-ready](http://stackoverflow.com/questions/2829483/loading-javascript-file-after-jquery-ready)
 * I also noticed that you said “I use this to defer loading misc.js that contains
   all of my custom js”, but your code says it’s looking for misc1.js? Is that a
   typo?
 *  [Dave McHale](https://wordpress.org/support/users/dmchale/)
 * (@dmchale)
 * [11 years ago](https://wordpress.org/support/topic/loading-jquery/#post-6099673)
 * Also, jQuery 1 is not “old”, strictly speaking. There are a few minor differences
   between 1 and 2, true, but mostly v1 is used when you want the highest compatibility
   with people’s browsers. jQuery2 stripped out a lot of the “bloat” that was necessary
   for older browser support, and only supports IE9+. [jQuery Browser Support](https://jquery.com/browser-support/)
 * jQuery 1 is still actively released, with the latest versions of 1 and 2 being
   released a little over a week ago. [http://blog.jquery.com/2015/04/28/jquery-1-11-3-and-2-1-4-released-ios-fail-safe-edition/](http://blog.jquery.com/2015/04/28/jquery-1-11-3-and-2-1-4-released-ios-fail-safe-edition/)
 *  Thread Starter [c-m](https://wordpress.org/support/users/c-m/)
 * (@c-m)
 * [11 years ago](https://wordpress.org/support/topic/loading-jquery/#post-6099676)
 * Yeah it’s misc1.js that was just typo in the post. Thanks I’ll look as the stackoverflow
   link and see what I can come up with.

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

The topic ‘Loading jQuery’ 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/)
 * 7 replies
 * 3 participants
 * Last reply from: [c-m](https://wordpress.org/support/users/c-m/)
 * Last activity: [11 years ago](https://wordpress.org/support/topic/loading-jquery/#post-6099676)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
