• Resolved Camilo

    (@camilo517)


    Hello, your plugin is very good, but I have detected an error that makes the performance of a website decrease
    /wp-content/plugins/material-design-for-contact-form-7/assets/js/cf7-material-design-bundle.js?ver=2.0

    That loads in all the pages. It should only load when it detects a form. Since this loads in entries, blog etc etc

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author GusRuss89

    (@gusruss89)

    Hi @camilo517,

    Thanks for filing this issue. It’s something I’ve considered, but the problem is that there is no way to detect whether a form is on the page from the wp_enqueue_scripts hook.

    I could change it so that the scripts are enqueued from inside the shortcode, but I’m honestly not sure if that is a good idea, or whether it might break in some circumstances.

    If you want to increase the performance for your own site, you can always do this in your functions.php:

    add_action( 'wp_enqueue_scripts', 'my_dequeue_cf7md', 90 );
    function my_dequeue_cf7md() {
      if( !is_page('contact') ) {
        wp_dequeue_script( 'cf7-material-design' );
        wp_dequeue_script( 'autosize' );
        wp_dequeue_style( 'cf7md_roboto' );
        wp_dequeue_style( 'cf7-material-design' );
      }
    }

    Obviously you would need to craft your own if condition.

    Thanks,
    Angus

    Hi, thanks for responding so fast!
    How can I do an if with the id of the page? Thank you

    I leave here the solution in case someone needs it
    it’s very simple:

    add_action( ‘wp_enqueue_scripts’, ‘my_dequeue_cf7md’, 90 );
    function my_dequeue_cf7md() {
    if( !is_page( 42 ) ) {
    wp_dequeue_script( ‘cf7-material-design’ );
    wp_dequeue_script( ‘autosize’ );
    wp_dequeue_style( ‘cf7md_roboto’ );
    wp_dequeue_style( ‘cf7-material-design’ );
    }
    }

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Error’ is closed to new replies.