Title: Recaptcha javascript error
Last modified: March 1, 2019

---

# Recaptcha javascript error

 *  [latcomsystems](https://wordpress.org/support/users/latcomsystems/)
 * (@latcomsystems)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/recaptcha-javascript-error/)
 * Line 60 in recaptcha.php gets an error grecpatcha is not defined
    because it 
   is loaded in the footer but all the other scripts are loaded with DEFER attribute
   by default, so grecaptcha does not exist at this point.
 * Author needs to surround the inline javasript with:
 * window.addEventListener(‘DOMContentLoaded’, function() {
    ( function( grecaptcha,
   sitekey ) {………. });
 * I fixed this on my client’s site and turned off updates to this plugin until 
   a fix is published.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Nikita_Sp](https://wordpress.org/support/users/nikitasp/)
 * (@nikitasp)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/recaptcha-javascript-error/#post-11027403)
 * Seems I’ve fond a solution.
 * On my client’s website the link for recaptcha ([https://www.google.com/recaptcha/api.js?render=SECRET-KEY&ver=3.0](https://www.google.com/recaptcha/api.js?render=SECRET-KEY&ver=3.0))
   responds 400 Bad request.
    Seems he didn’t add the domain to the allowed one.
 * But, if you’re telling that your solution is working, maybe you have some issues
   and conflicts in your custom code?
 * Thanks.
 *  [sherpadawan](https://wordpress.org/support/users/sherpadawan/)
 * (@sherpadawan)
 * [7 years, 4 months ago](https://wordpress.org/support/topic/recaptcha-javascript-error/#post-11132214)
 * You should set priority to 1 instead of 40 at line 45
 * add_action( ‘wp_footer’, ‘wpcf7_recaptcha_onload_script’, 1, 0 );
 *  [sherpadawan](https://wordpress.org/support/users/sherpadawan/)
 * (@sherpadawan)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/recaptcha-javascript-error/#post-11135787)
 * [@cag8f](https://wordpress.org/support/users/cag8f/) I replied according to the
   result of the thread.
 *     ```
       diff --git a/htdocs/wp-content/plugins/contact-form-7/modules/recaptcha.php b/htdocs/wp-content/plugins/contact-form-7/modules/recaptcha.php
       index 5cb45e8..19e74ce 100755
       --- a/htdocs/wp-content/plugins/contact-form-7/modules/recaptcha.php
       +++ b/htdocs/wp-content/plugins/contact-form-7/modules/recaptcha.php
       @@ -42,7 +42,7 @@ function wpcf7_recaptcha_add_hidden_fields( $fields ) {
               ) );
        }
   
       -add_action( 'wp_footer', 'wpcf7_recaptcha_onload_script', 40, 0 );
       +add_action( 'wp_footer', 'wpcf7_recaptcha_onload_script', 1, 0 );
   
        function wpcf7_recaptcha_onload_script() {
               $service = WPCF7_RECAPTCHA::get_instance();
       @@ -57,7 +57,6 @@ function wpcf7_recaptcha_onload_script() {
       ```
   

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Recaptcha javascript error’ is closed to new replies.

 * ![](https://ps.w.org/contact-form-7/assets/icon.svg?rev=2339255)
 * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7/reviews/)

## Tags

 * [javascript error](https://wordpress.org/support/topic-tag/javascript-error/)

 * 3 replies
 * 3 participants
 * Last reply from: [sherpadawan](https://wordpress.org/support/users/sherpadawan/)
 * Last activity: [7 years, 3 months ago](https://wordpress.org/support/topic/recaptcha-javascript-error/#post-11135787)
 * Status: not resolved