• CF7 WAS a very good plugin. WAS! Because with latest versions JS- and CSS-Files and recaptcha (recaptcha__de.js) loads on EVERY page and post! This has a huge impact on the website. In 2020 speed is a huge ranking factor for google and will be more important in 2021 and the next years.

    If the author fixes this strange behavior, so that the CF7-Files will ONLY load on pages / post where CF7 ist integrated, the plugin could become one of the most recommended plugins again. But for now … stay away from it!

    • This topic was modified 3 years, 11 months ago by The-Dude.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello @the-dude-1,

    In fact, if I remember correctly, CF7 has always loaded CSS and JS on all pages to make sure the forms work properly (not only since the last version). This is a topic discussed many times in the plugin support forum and there are several technical reasons why it’s not added to the core of the plugin. However, there are also several ways to solve it.

    My recommendation is to follow the steps you’ll find in this article from the official documentation: Loading JavaScript and stylesheet only when it is necessary.

    If you prefer to use a code snippet, you can try adding this one in the functions.php file of your child theme or using a custom plugin (recommended):

    add_action( 'wp_enqueue_scripts', 'wpcf7_scripts_removal_contact_form_7', 999);
    
    function wpcf7_scripts_removal_contact_form_7() {
      
      global $post;
      
      if( is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'contact-form-7') ) {
        
        wp_enqueue_script('contact-form-7');
        wp_enqueue_style('contact-form-7');
        ?
      } else {
        
        wp_dequeue_script( 'contact-form-7' );
        wp_dequeue_style( 'contact-form-7' );
        
      }
    }

    This code snippets will remove the CSS and JS of CF7 from all post and pages that don’t include a CF7 form shortcode in its content. Please note this also remove the CSS and JS from the archives pages and widgets, so it’s not a good idea to use it if you have set a form within a widget.

    Hope this helps you.

    Best regards,
    Yordan.

    “In 2020 speed is a huge ranking factor for google and will be more important in 2021 and the next years.”

    Prove it.

    I have the same issue. That is, CF7 is THE bottleneck on my pageloads and adds a 1-2 seconds to the time to load each page. Here is the problem. I am using AVADA theme and have on every page two different forms that are using a popup modal. That is, a button that when clicked on will activate a modal popup with the appropriate form.

    I do this so the user can quickly access the form without having to click away from the page.

    Consequently, every time a page is loaded ALL of the CSS and JS scrips are loaded TWICE causing a big slowdown.

    Is there a way to roll back to a leaner version of CF7 or a way to “lazy load” these scrips so that pages/posts load faster?

    HELP!

    Peter

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Slows down site’ is closed to new replies.