• Resolved egornmore

    (@egornmore)


    Hello, I noticed that plugin scripts and styles are loaded on every page even if it’s not used. How can I dequeue scripts and styles?

    /plugins/contact-form-7-multi-step-pro//assets/frontend/css/cf7mls.css?ver=2.6.8 -> 2.10B /plugins/contact-form-7-multi-step-pro//assets/frontend/css/progress_bar.css?ver=2.6.8 -> 5.56KB /plugins/contact-form-7-multi-step-pro//assets/frontend/animate/animate.min.css?ver=2.6.8 -> 4.89KB

    Thanks in advance

Viewing 8 replies - 1 through 8 (of 8 total)
  • Hi @egornmore ,

    Thanks for reaching out!

    Please let me check this with the dev and I will feed you back as soon as possible.

    Kind regards,
    Alina

    Plugin Support mialewp

    (@mialewp)

    Hi @egornmore ,

    Thanks for your patience. In frontend there is no way to determine which exactly page has been used contact form to load scripts file and styles. Even Contact form 7 also works like this. But you can try by referring to this doc https://developer.www.ads-software.com/reference/hooks/wp_enqueue_scripts/
    Hope that clears. If you need further help, please let us know.

    Many thanks!
    Mia

    Thread Starter egornmore

    (@egornmore)

    Hi @mialewp,

    I can target the page manually, by is_page(id). Should dequeue be something like that – remove_action('wp_enqueue_scripts', 'cf7mls', 20, 0); ?

    Hi @egornmore ,

    Please use this function:

    wp_dequeue_script( 'cf7mls' )

    Kind regards,
    Alina

    • This reply was modified 1 year, 9 months ago by alina98.
    Thread Starter egornmore

    (@egornmore)

    Tried wp_dequeue_style( 'cf7mls-css' );, wp_dequeue_style( 'cf7mls' );,wp_dequeue_script( 'cf7mls' ); but styles and scripts still there

    • This reply was modified 1 year, 9 months ago by egornmore.

    Hi @egornmore ,

    Please let me check this with the dev and I will feed you back as soon as possible.

    Kind regards,
    Alina

    Plugin Support mialewp

    (@mialewp)

    Hi @egornmore ,

    Please try to use this code

    add_action( ‘wp_enqueue_scripts’, ‘remove_cf7mls_scripts_and_style’ );

    function remove_cf7mls_scripts_and_style() {

    wp_dequeue_style( ‘cf7mls-css’ );

    wp_dequeue_style( ‘cf7mls’ );

    wp_dequeue_script( ‘cf7mls’ );

    }
    If you have any questions, feel free to contact us.

    Many thanks!
    Mia

    Thread Starter egornmore

    (@egornmore)

    Hi @mialewp that solution works for me, thanks!

    Also added animate and progress bar styles:

    add_action( 'wp_enqueue_scripts', 'remove_cf7mls_scripts_and_style' );

    function remove_cf7mls_scripts_and_style() {
    if(!is_page($id)) {
    wp_dequeue_style('cf7mls');
    wp_dequeue_script('cf7mls');
    wp_dequeue_style('cf7mls_animate');
    wp_dequeue_style('cf7mls_progress_bar');
    }
    }

    • This reply was modified 1 year, 9 months ago by egornmore.
    • This reply was modified 1 year, 9 months ago by egornmore.
Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Dequeue Scripts/Styles’ is closed to new replies.