Forum Replies Created

Viewing 1 replies (of 1 total)
  • Hi,

    If you really want to control on which pages to load reCaptch or not, please use this :

    wp_dequeue_script('google-recaptcha');
    

    And you can choose to enable or not on specific pages like this :

    // display only on page with slug 'contact'
    if (! is_page('contact')) {
      wp_dequeue_script('google-recaptcha');
    }
    

    Finally, you can add this hook to your functions.php :

    function cf7_dequeue_scripts() {  
        if (! is_page('contact')) {        
            wp_dequeue_script('contact-form-7');
            wp_dequeue_script('google-recaptcha');
        }
    }
    add_action('wp_print_scripts','cf7_dequeue_scripts', 100);
    

    IMHO, this is best practice if you only use reCaptcha v3 for Contact Form 7 plugin.
    EDIT : as said @lofesa in a similar post, it’s good to disable the whole contact-form-7 script on pages you don’t need it. This will avoid useless script loading.

    ibcht

    • This reply was modified 9 months, 3 weeks ago by ibcht.
    • This reply was modified 9 months, 3 weeks ago by ibcht.
    • This reply was modified 9 months, 3 weeks ago by ibcht.
    • This reply was modified 9 months, 3 weeks ago by ibcht.
Viewing 1 replies (of 1 total)