TypeError: grecaptcha.execute is not a function means the object sitting on window.grecaptcha has no execute when your code asks for it. There are two usual reasons. The library has not finished loading, or the object on the page belongs to reCAPTCHA Enterprise, which keeps execute one level down under grecaptcha.enterprise. We hit the second one on Google's own reCAPTCHA v3 demo, about one load in three.

Where we met the error

Our detection suite runs 49 public test pages against a Mosaic profile and reads each verdict. One row is Google's reCAPTCHA v3 demo at recaptcha-demo.appspot.com, because it is one of very few pages that print the numeric v3 score instead of hiding it. The row was failing intermittently: no score on the page, while a stock browser measured in the same session got its score every time. Four runs of one profile came back pass, pass, unread, unread. The stock browser went pass, pass, pass.

That pattern looks exactly like a finding about the profile. It was not one. With an error listener installed at document start, the failing loads all threw the same thing, inside Google's code: TypeError: grecaptcha.execute is not a function.

Two scripts, one global

The demo page loads two libraries. One is api.js?render=…, the ordinary v3 library. The other is enterprise.js?render=…, the Enterprise one. Both define window.grecaptcha, and they do not agree on its shape. In v3, execute and ready sit on grecaptcha itself. In Enterprise they sit on grecaptcha.enterprise.

So the order the two arrive in decides what the page's own call finds. The resource timings from one passing load and one failing load:

pass    api.js 180ms   enterprise.js 421ms
fail    api.js 156ms   enterprise.js  97ms   TypeError: grecaptcha.execute
                                             is not a function

On the failing load Enterprise was on the page first, the demo called grecaptcha.execute(…) on an object that keeps it elsewhere, and no token was ever requested. The stock browser happened to win it on every load we measured, but the race says nothing about the profile. It is two of Google's own scripts on Google's own demo.

Everything the window does, from a script on your own computerIn Mosaic: REST API. Everything the window does, from your own scripts. Free covers 3 profiles with no card, and Pro is $25 a month for any number of them.

How it works: REST API

The check that could never fail

Our first fix was a probe that asked the page whether grecaptcha.execute was a function. On four failing loads it said yes, every time. By the time the suite reads the page, the other library has landed and replaced the object, and the key list on window.grecaptcha is identical to a healthy page's. The library that lost finished loading a moment after the throw, so nothing left on the page shows the failure.

A check that cannot fail is not a check, and that one would have sat in the suite reading like one. What does differ is the demo's own status log, which narrates each step. Both outcomes print grecaptcha.ready() fired, calling and then grecaptcha.execute('…', {action: 'examples/v3scores'}). Only a passing load goes on to print Received token from reCAPTCHA service. The Try again link is no use: it is rendered on the passing page too.

So the row now reads the log. When it stops at the execute line, the suite reports it as unread and says the page's own library broke before asking for a token, which sends nobody off to investigate the profile's reputation. The row also polls for the score instead of sleeping a fixed time, because a fixed sleep, already raised from 20 seconds to 35, kept recording slow loads as pages that rendered nothing.

Fixing grecaptcha.execute is not a function on your own site

If the error is in your code rather than in a demo, the cause is usually one of these:

  1. The call runs before the library is ready. Wrap it: grecaptcha.ready(() => grecaptcha.execute(siteKey, { action: 'submit' })). With a script loaded async or injected late, a bare execute at page load works on a fast connection and fails on a slow one.
  2. The page loads enterprise.js. Enterprise keys and the Enterprise script use grecaptcha.enterprise.ready and grecaptcha.enterprise.execute. The v3 names are not there.
  3. The page loads both. A tag manager, a plugin and a theme can each add their own copy. The order they arrive in decides which shape window.grecaptcha has when your callback runs, so the error comes and goes with the network. Search the page for every recaptcha/api.js and recaptcha/enterprise.js and keep one.
  4. The script URL has no render= site key. v3's execute(siteKey, …) needs the library loaded with ?render=<your site key>. Loaded with render=explicit, execute belongs to the invisible v2 widget and takes a widget id.

When you test the fix, test it twice, on a throttled connection. A race that wins on the first try is the reason this bug ships.

What we took from it

The cheapest check was to run an untouched browser beside the profile, and it was right there in the tool. The rule we keep relearning is that a stock browser goes in the same run, at both ends, before a verdict counts as a fact about our engine. The control that settles "is it our changes to Chromium?" is the same lesson with four lost days attached, and Pixelscan's false positives on a stock Chrome is it again with numbers. The full list of pages the suite reads, and what each verdict means, is in our 49 detectors.