• I just updated the plugin through WP today with the latest update and my site is no scoring lower for mobile on the Google PageSpeed test.

    My pages were scoring 90+ for mobile and after the update they score for around 80.

    This is on pages where there are no forms.

    I have confirmed that this plugin is the problem by deactivating it and texting and re-activating it.

Viewing 7 replies - 1 through 7 (of 7 total)
  • I suggest you consider placing the form not on home page but on a dedicated page, so possibly home page won’t slow down, if no CF7 is part of it.

    I see the same on my side. The site increases from 49kB to 129kB after activating CF7. Before I upgrade to version 5.4 my site loads less than 90kB with CF7. I think CF 7 use a lot of new js libraries or code on every page. How can I fix this?

    • This reply was modified 3 years, 9 months ago by sallius.
    Thread Starter atlas99

    (@atlas99)

    “I suggest you consider placing the form not on home page but on a dedicated page, so possibly home page won’t slow down, if no CF7 is part of it”

    I only have the form on one contact page, yet it is slowing down every single page

    After the 5.4 update, if you want to load CF7’s JS and CSS only on pages/posts where a CF7 shortcode is present you can put the following code in your child-theme’s functions.php (backup it first!).

    Hope this helps.

    /**
     * Conditionally Load CF7's Scripts and Styles Only Where Needed
     */
     
    /**
     * Dequeue:
     * 
     * contact-form-7
     * wp-i18n
     * lodash
     * wp-url
     * wp-hooks
     * wp-api-fetch
     * wp-polyfill (To completely dequeue this, also dequeue recaptcha scripts - see below)
     */
    add_filter( 'wpcf7_load_js', '__return_false' );
    
    // Dequeue contact-form-7 CSS
    add_filter( 'wpcf7_load_css', '__return_false' );
    
    function conditionally_enqueue_cf7_js_css() {
    
    	// Dequeue wpcf7-recaptcha
        wp_dequeue_script('wpcf7-recaptcha');
    	
    	// Dequeue google-recaptcha
    	wp_dequeue_script( 'google-recaptcha' );
    
        // If current post has cf7 shortcode, enqueue everything back
        global $post;
        if ( isset( $post->post_content ) AND has_shortcode( $post->post_content, 'contact-form-7' ) ) {
    		
            if ( function_exists( 'wpcf7_enqueue_scripts' ) ) {
                wpcf7_enqueue_scripts();
    			wp_enqueue_script('wpcf7-recaptcha');
                wp_enqueue_script( 'google-recaptcha' );
            }
    		
    		if ( function_exists( 'wpcf7_enqueue_styles' ) ) {
    			wpcf7_enqueue_styles();
    		}
        }
    }
    add_action( 'wp_enqueue_scripts', 'conditionally_enqueue_cf7_js_css', 20, 0 );

    In addition to my previous post..

    In case you’re using any scripts optimization plugins (WP Rocket, Autoptimize, etc.) and your are facing CF7 (5.4) related console errors, you should exclude from defer the following scripts:

    /jquery-?[0-9.]*(.min|.slim|.slim.min)?\.js
    /wp-includes/js/dist/vendor/wp-polyfill.min.js
    /wp-includes/js/dist/vendor/lodash.min.js
    /wp-includes/js/dist/api-fetch.min.js
    /wp-includes/js/dist/url.min.js
    Thread Starter atlas99

    (@atlas99)

    Thanks for the workaround, although I don’t think I will be using it. I don’t want to have to maintain code for this in a child theme.

    This should be default for this plugin, I don’t know why it would load on pages without form code.

    At this time I’m going to be looking into other contact form options

    [ Please do not bump. ]

    Same issue.
    CF7 Started adding many different JS Files

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Site Speed Slower after Update Today’ is closed to new replies.