• Resolved Jairo Ochoa

    (@jairoochoa)


    Hi

    If checked Remove Query Strings from Static Resources when using Contact Form 7 there is an error in Console.

    Uncaught TypeError: grecaptcha.execute is not a function
        at b (wpcf7-recaptcha.min.js:1:255)
        at HTMLDocument.<anonymous> (wpcf7-recaptcha.min.js:1:543)
    b @ wpcf7-recaptcha.min.js:1
    (anónimo) @ wpcf7-recaptcha.min.js:1

    If this option is disabled the error disappears.

    Please check this: https://www.ads-software.com/support/topic/again-grecaptcha-execute-is-not-a-function/

    Probably it only happens if Google reCaptcha is active in Contact Form 7

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Plamen M

    (@plamenm)

    Hello @jairoochoa ,

    I installed a fresh instance of WordPress + SiteGround Optimizer + Contact Form 7 + reCAPTCHA v3 setup. This setup, with all Caching and Frontend options enabled in the SiteGround Optimizer plugin (including the option Remove Query Strings from Static Resources) did not result in the reported error:

    https://prnt.sc/8moorTouYdKw

    Most probably, there is a conflict with another plugin or the theme that you are using. I would advise you to try to disable your plugins one by one and to temporarily revert the theme to the default for WordPress to identify which plugin or theme is causing the error in your setup.

    We remain available for further assistance.

    Regards,
    Plamen.M
    Tech Support Team
    SiteGround.com

    Thread Starter Jairo Ochoa

    (@jairoochoa)

    Hi @plamenm

    Please check in pages without any form.
    Thanks

    Plugin Support Georgi Ganchev

    (@georgiganchev)

    Hello @jairoochoa ,

    We tried to replicate the issue but to no avail. Yet I did some checks and it appears that such an issue is experienced with other caching plugins and specifically when the Query string removal option is enabled. What this does is remove version query strings from your static resources improving the caching of those resources.

    If this is causing issues, you may want to check directly with the Google reCaptcha developers since I see that this issue is not experienced unless both Contact Form 7 and Google ReCaptcha plugins are active.

    You can also keep the option deactivated from SiteGround Optimizer if it causes issues with your application. We would be able to check further only if you open a ticket through your Client area so we can replicate the issue on your website.

    Best regards,
    Georgi

    Thread Starter Jairo Ochoa

    (@jairoochoa)

    Hi

    I will do a test with these functions in order to load CF7 libraries only where necessary:

    if ( !function_exists('cmdm_wpcf7_dequeue_scripts') ) 
    {
    	function cmdm_wpcf7_dequeue_scripts() 
    	{
    		wp_dequeue_script( 'contact-form-7' );
    		wp_dequeue_style ( 'contact-form-7' );
    		wp_dequeue_script( 'wpcf7-recaptcha' );
    		wp_dequeue_style ( 'wpcf7-recaptcha' );
    		wp_dequeue_script( 'google-recaptcha' );
    	}
    	
    	add_action( 'wp_enqueue_scripts', 'cmdm_wpcf7_dequeue_scripts', 11 );
    }

    and this one:

    if ( !function_exists('cmdm_wpcf7_enqueue_scripts') ) 
    {
    	function cmdm_wpcf7_enqueue_scripts()
    	{
    		$load_scripts = false;
    	
    		if ( is_singular() )
    		{
    			$post = get_post();
    			
    			if ( has_shortcode( $post->post_content, 'contact-form-7' ) ) 
    			{
    				$load_scripts = true;
    			}
    		}
    		
    		if ( $load_scripts )
    		{
    			if ( function_exists( 'wpcf7_enqueue_scripts' ) ) wpcf7_enqueue_scripts();
    			if ( function_exists( 'wpcf7_enqueue_styles' ) ) wpcf7_enqueue_styles();
    		}
    	}
    }
    
    add_action( 'wp_enqueue_scripts', 'cmdm_wpcf7_enqueue_scripts', 99 );

    I guess that will prevent the bug.

    String removal is necessary but somehow it makes CF7 to fail.

    Otherwise “Remove Query Strings from Static Resources” could have an option, like others in SG Optimizer, which allow to exclude scripts.

    Best

    • This reply was modified 2 years, 2 months ago by Jairo Ochoa.
    Plugin Support Delyan Delov

    (@delyandelov)

    Hello @jairoochoa,

    I have passed your suggestion for implementing an exclude list for the “Remove Query Strings from Static Resources” functionality. You can check the future releases of the plugin for such an update.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Contact Form 7 + Remove Query Strings from Static Resources’ is closed to new replies.