• Resolved Rufus McDufus

    (@rufus-mcdufus)


    Hi – I have a conflict with TML and the Contact Form 7 plugin. The problem is that TML appears to load the Recaptcha Javascript (https://www.google.com/recaptcha/api.js) on every page (not just the registration page where it’s intended for). In a browser web console this results in the Javascript error:

    Error: ReCAPTCHA placeholder element must be empty

    A side effect of this is that send confirmation messages are broken with CF7 which is causing problems for users. Page load times are often very slow on the contact form page too, though I don’t know if this is the result of the two calls to recaptca/api.js.
    I can’t figure how to work around this, and can’t think if something other than TML is causing it. I’ve tried disabling all plugins except TML, but it still seems to load on every page. Site is running PHP7, PHP-FPM & Opcache if it’s relevant.

    • This topic was modified 7 years, 8 months ago by Rufus McDufus.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Jeff Farthing

    (@jfarthing84)

    TML loads it on all pages because there is no telling if you are using the widget or not. You can dequeue it for everywhere except the registration page:

    
    function tml_dequeue_recaptcha_js() {
        if ( ! Theme_My_Login::get_object()->is_tml_page( 'register' ) ) {
            wp_dequeue_script( 'recaptcha' );
        }
    }
    add_action( 'wp_enqueue_scripts', 'tml_dequeue_recaptcha_js', 15 );
    
    Thread Starter Rufus McDufus

    (@rufus-mcdufus)

    Thank you so much – that works absolutely perfectly and all is good now!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Recaptcha JS loading on every page’ is closed to new replies.