Title: wp_dequeue_script page speed help
Last modified: February 21, 2018

---

# wp_dequeue_script page speed help

 *  [rmsgreig](https://wordpress.org/support/users/rmsgreig/)
 * (@rmsgreig)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/wp_dequeue_script-page-speed-help/)
 * I have created a custom wp_dequeue script function in my functions.php, some 
   of the dequeues work fine but others are simply ignored, i have cut the example
   code down to only include some of those that are not working:
 *     ```
       add_action('wp_enqueue_scripts','custom_conditional_loading');  
   
       function custom_conditional_loading(){
   
       	wp_dequeue_script('jquery-ui-core');
       	wp_dequeue_script('moment-js');
       	wp_dequeue_script('moment-core-js');
        if(! is_page(825))
          {
   
       	 wp_enqueue_script('jquery-ui-core');
       	 wp_enqueue_script('moment-js');
       	 wp_enqueue_script('moment-core-js');
          }
       }
       ```
   
 * I am really trying to improve the performance on the website and there are a 
   lot of unnecessary files being loaded, am I doing this wrong?

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

 *  [Simon Prosser](https://wordpress.org/support/users/pross/)
 * (@pross)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/wp_dequeue_script-page-speed-help/#post-9998922)
 * HI there.
 * Take a quick look at the docs, you need to use a different action and add a priority
   to ensure it runs after your script is enqueued but before the script is actually
   printed.
    [https://developer.wordpress.org/reference/functions/wp_dequeue_script/](https://developer.wordpress.org/reference/functions/wp_dequeue_script/)
 *  Thread Starter [rmsgreig](https://wordpress.org/support/users/rmsgreig/)
 * (@rmsgreig)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/wp_dequeue_script-page-speed-help/#post-9999716)
 * Thanks for the guidance, I have updated my code:
 *     ```
       add_action('wp_print_scripts','custom_conditional_loading', 100 );    
   
       function custom_conditional_loading(){
   
          if(!is_page(825))
          {
       	 wp_dequeue_script('jquery-ui-core');
       	 wp_dequeue_script('moment-js');
       	 wp_dequeue_script('moment-core-js');
          }
       }
       ```
   
 * But still no luck, I can deregister the scripts, but then they won’t load on 
   the pages they are supposed to, I even tried copying and pasting the example 
   you gave above and this didn’t work either, any ideas?
    thanks
 *  [Simon Prosser](https://wordpress.org/support/users/pross/)
 * (@pross)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/wp_dequeue_script-page-speed-help/#post-9999725)
 * If you can deregister them then use is_page there.
 *  Thread Starter [rmsgreig](https://wordpress.org/support/users/rmsgreig/)
 * (@rmsgreig)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/wp_dequeue_script-page-speed-help/#post-9999737)
 * I tried to deregister and then register on a specific page using is_page but 
   it didn’t register them?

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

The topic ‘wp_dequeue_script page speed help’ is closed to new replies.

## Tags

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

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 4 replies
 * 2 participants
 * Last reply from: [rmsgreig](https://wordpress.org/support/users/rmsgreig/)
 * Last activity: [8 years, 1 month ago](https://wordpress.org/support/topic/wp_dequeue_script-page-speed-help/#post-9999737)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
