title: Invisible captcha executed as soon as page loads
body: <p>I'm trying to use the ability of google to check if the page request comes from a human or bot.
  By this I want to include an invisible captcha and submit the verification as soon as the page finishes loading.
  I've gone through the google docs <a href="https://developers.google.com/recaptcha/docs/invisible" rel="nofollow noreferrer">https://developers.google.com/recaptcha/docs/invisible</a> and the normal example works fine for me. But I'm trying to tweak it in a way the grecaptcha.execute() fires off as soon as the page loads, I've tryied with window.onload, or (window).ready() and I get the same error of</p>
  
  <pre><code>grecaptcha is not defined
  </code></pre>
  
  <p>Of course I believe it is because the grecaptcha script is not ready, in fact if I set a timeout of 1sec or 2 secs, it will execute fine.</p>
  
  <p>I tried to add the "onload" parameter to the api.js with no luck... and by the way the api.js just includes the actual recaptcha script in the HEAD "recaptcha__en.js"</p>
  
  <p>I do not need an actual FORM or submit any contact information, just need to verify if the subject viewing the page is a human or a bot</p>
  
  <p>any ideas/suggestions will be appreciated!
  thanks!!</p>
  
  <p>EDIT: adding code as requested:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;script&gt;
          //called only when I set the timeout
          function onSubmit(){
              console.log("Submitted")
          }
  
          //not being called by the "onload parameter of the api.js script"
          function loadCaptcha(){
            console.log("loaded")
            setTimeout(function(){grecaptcha.execute()},2000)
          }
  
      &lt;/script&gt;
      &lt;script src='https://www.google.com/recaptcha/api.js' async defer&gt;&lt;/script&gt;
      &lt;!--&lt;script src='https://www.google.com/recaptcha/api.js?onload="loadCaptcha"' async defer&gt;&lt;/script&gt;----it doesnt make any difference for my case--&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div class="g-recaptcha"
        data-sitekey="xxxxxxxxxxxxxxxxxxxxxxxxxx"
        data-callback="onSubmit"
        data-size="invisible"&gt;
  &lt;/div&gt;
  &lt;script&gt;
      //Window.onload = setTimeout(function(){grecaptcha.execute()},2000) this works!
      Window.onload = grecaptcha.execute() //----this doesn't work---//
  
  &lt;/script
  &lt;/body&gt;
  </code></pre>
  
  <p></p>