Title: $GLOBALS[&#039;wp_scripts&#039;] is empty
Last modified: August 31, 2016

---

# $GLOBALS['wp_scripts'] is empty

 *  [newleaves](https://wordpress.org/support/users/newleaves/)
 * (@newleaves)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/globalswp_scripts-is-empty/)
 * I’ve noticed this happen in the past temporarily but now it’s a permanent issue.
   It was happening on 4.4 and still happening on 4.5.
    I’m trying to get the packaged
   version of jquery with $GLOBALS[‘wp_scripts’]->registered[‘jquery’] but it’s 
   empty. however, the list exists if i login to wordpress first and have the adminbar
   loaded.
 *     ```
       add_action('wp_enqueue_scripts', function(){
         $system_jquery = $GLOBALS['wp_scripts']->registered['jquery'];
         wp_deregister_script('jquery');
       });
       ```
   
 * i’ve tried adding a priority value for the add_action.

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

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/globalswp_scripts-is-empty/#post-7296865)
 * I’ve been unable to find _any_ condition where ‘jquery’ is not registered on 
   my site, which is the only way `registered['jquery']` would be empty. Logged 
   in or not, admin bar or not, anything. Are you sure your theme or some other 
   plugin is not deregistering ‘jquery’? If it’s empty, there’s nothing to deregister
   anyway. Deregistering ‘jquery’ without registering another version will break
   things. Explicitly loading jQuery by echoing a meta link is doing it wrong.
 * BTW, to check for ‘jquery’ on the backend hook ‘admin_enqueue_scripts’
 *  Thread Starter [newleaves](https://wordpress.org/support/users/newleaves/)
 * (@newleaves)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/globalswp_scripts-is-empty/#post-7296875)
 * ok, i was hoping there was a common pitfall for ending up with an empty wp_scripts.
   i’ll dig around some more.
    I just need the version of the default registered
   jquery. googleapis cdn hasn’t added 1.12.3 to their line-up yet, so i’m using
   this snippet to prevent a missing jquery.js file from bringing the site down:
 *     ```
       $system_jquery = $GLOBALS['wp_scripts']->registered['jquery'];
       wp_deregister_script('jquery');
       wp_deregister_script('jquery-migrate');
       wp_enqueue_script('jquery', "//ajax.googleapis.com/ajax/libs/jquery/{$system_jquery->ver}/jquery.min.js", [], $system_jquery->ver, true);
       add_filter('script_loader_src', function($src, $handle = null) use($system_jquery){
         static $add_jquery_fallback = false;
         if ($add_jquery_fallback) { ?>
           <script>window.jQuery || document.write('<script src="//code.jquery.com/jquery-<?= $system_jquery->ver ?>.min.js"><\/script>')</script>
           <script>window.jQuery || document.write('<script src="<?= includes_url('/js/jquery/jquery.js') ?>"><\/script>')</script>
           <script>if ($ !== window.jQuery) $ = window.jQuery</script>
         <? }
         $add_jquery_fallback = ($handle === 'jquery');
         return $src;
       }, 10, 2);
       ```
   

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

The topic ‘$GLOBALS['wp_scripts'] is empty’ is closed to new replies.

## Tags

 * [cdn](https://wordpress.org/support/topic-tag/cdn/)
 * [empty](https://wordpress.org/support/topic-tag/empty/)
 * [globals](https://wordpress.org/support/topic-tag/globals/)
 * [wp_scripts](https://wordpress.org/support/topic-tag/wp_scripts/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 2 replies
 * 2 participants
 * Last reply from: [newleaves](https://wordpress.org/support/users/newleaves/)
 * Last activity: [10 years, 1 month ago](https://wordpress.org/support/topic/globalswp_scripts-is-empty/#post-7296875)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
