Support » Plugin: WP Menu Cart » Dequeue scripts and styles

  • Resolved bnfw



    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,

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Ewout


    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);


    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 Author Jeremiah


    Hi Voltronik.

    What e-commerce plugin are you using this with? Also, is this live so we can take a look?


    Plugin Author Ewout


    Hi Jack,
    That’s because the wpmenucart script is localized. If you’re not using that script anymore, you’ll have to localize your own script with the wpmenucart_ajax variable:

    			'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).

    That worked perfectly!
    Thank you very much for your help.


Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Dequeue scripts and styles’ is closed to new replies.