Title: Dequeue scripts and styles
Last modified: August 21, 2016

---

# Dequeue scripts and styles

 *  Resolved [Jack – BNFW](https://wordpress.org/support/users/voltronik/)
 * (@voltronik)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/dequeue-scripts-and-styles/)
 * Hi,
 * I’m trying to minimise the amount of stylesheets and scripts being loaded by 
   a site i’m working on. I’m already including FontAwesome in my theme and can 
   easily include the CSS and JS that WP Menu Cart is inserting in my own, minimised
   LESS and JS files.
 * I’ve tried a number of things and added the following to my theme but it doesn’t
   work.
 *     ```
       wp_dequeue_style( 'wpmenucart-icons' ); // FontAwesome
       wp_dequeue_style( 'wpmenucart' ); // Styles
       ```
   
 * Can you tell me what I need to do remove them?
 * Thanks for any help in advance,
    Jack
 * [http://wordpress.org/plugins/wp-menu-cart/](http://wordpress.org/plugins/wp-menu-cart/)

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

 *  Plugin Contributor [Ewout](https://wordpress.org/support/users/pomegranate/)
 * (@pomegranate)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/dequeue-scripts-and-styles/#post-4497668)
 * Hi Jack,
    Have you tried putting that in a function? You’re probably to early
   to dequeue (i.e. it’s not enqueued yet). If you hook into `wp_print_styles` it’ll
   probably work.
 *     ```
       function  dequeue_styles() {
           wp_dequeue_style( 'wpmenucart-icons' ); // FontAwesome
           wp_dequeue_style( 'wpmenucart' ); // Styles
       }
       add_action('wp_print_styles', 'dequeue_styles', 99999);
       ```
   
 * Ewout
 *  Thread Starter [Jack – BNFW](https://wordpress.org/support/users/voltronik/)
 * (@voltronik)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/dequeue-scripts-and-styles/#post-4497678)
 * Thanks, that’s great. That works.
 * I’ve also done that for the js script but I’m getting the error:
    ReferenceError:
   Can’t find variable: wpmenucart_ajax in the console.
 * Is there anything I can do about this?
 *  Plugin Contributor [Jeremiah](https://wordpress.org/support/users/jprummer/)
 * (@jprummer)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/dequeue-scripts-and-styles/#post-4497803)
 * Hi Voltronik.
 * What e-commerce plugin are you using this with? Also, is this live so we can 
   take a look?
 * Jeremiah
 *  Plugin Contributor [Ewout](https://wordpress.org/support/users/pomegranate/)
 * (@pomegranate)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/dequeue-scripts-and-styles/#post-4497805)
 * Hi Jack,
    That’s because the wpmenucart script is [localized](http://codex.wordpress.org/Function_Reference/wp_localize_script).
   If you’re not using that script anymore, you’ll have to localize your own script
   with the wpmenucart_ajax variable:
 *     ```
       wp_localize_script(
       	'YOURSCRIPT',
       	'wpmenucart_ajax',
       		array(
       			'ajaxurl' => admin_url( 'admin-ajax.php' ), // URL to WordPress ajax handling page
       			'nonce' => wp_create_nonce('wpmenucart')
       		)
       );
       ```
   
 * you have to put this **after** the code where you do your own `wp_enqueue_script`(
   and replace YOURSCRIPT with your own script handle).
 *  Thread Starter [Jack – BNFW](https://wordpress.org/support/users/voltronik/)
 * (@voltronik)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/dequeue-scripts-and-styles/#post-4497850)
 * That worked perfectly!
    Thank you very much for your help.
 * Jack

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

The topic ‘Dequeue scripts and styles’ is closed to new replies.

 * ![](https://ps.w.org/wp-menu-cart/assets/icon-256x256.png?rev=2190480)
 * [WP Menu Cart](https://wordpress.org/plugins/wp-menu-cart/)
 * [Support Threads](https://wordpress.org/support/plugin/wp-menu-cart/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-menu-cart/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-menu-cart/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-menu-cart/reviews/)

## Tags

 * [dequeue](https://wordpress.org/support/topic-tag/dequeue/)
 * [script](https://wordpress.org/support/topic-tag/script/)
 * [style](https://wordpress.org/support/topic-tag/style/)

 * 5 replies
 * 3 participants
 * Last reply from: [Jack – BNFW](https://wordpress.org/support/users/voltronik/)
 * Last activity: [12 years, 4 months ago](https://wordpress.org/support/topic/dequeue-scripts-and-styles/#post-4497850)
 * Status: resolved