You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`loadAsync`| Boolean | No |`true`| Set if the script should be loaded asynchronously. |
36
-
|`cleanup`| Boolean | No |`true`| Remove script tag after setup. |
37
-
|`crossOrigin`| String | No |`-`| Set script cross origin attribute such as "anonymous". |
38
-
|`scriptSource`| String | No |`https://js.hcaptcha.com/1/api.js`| Set script source URI. Takes precedence over `secureApi`. |
39
-
|`scriptLocation`| HTMLElement | No |`document.head`| Location of where to append the script tag. Make sure to add it to an area that will persist to prevent loading multiple times in the same document view. |
40
-
|`secureApi`| Boolean | No |`false`| See enterprise docs. |
41
-
|`apihost`| String | No |`-`| See enterprise docs. |
42
-
|`assethost`| String | No |`-`| See enterprise docs. |
43
-
|`endpoint`| String | No |`-`| See enterprise docs. |
44
-
|`hl`| String | No |`-`| See enterprise docs. |
45
-
|`host`| String | No |`-`| See enterprise docs. |
46
-
|`imghost`| String | No |`-`| See enterprise docs. |
47
-
|`recaptchacompat`| String | No |`-`| See enterprise docs. |
48
-
|`reportapi`| String | No |`-`| See enterprise docs. |
49
-
|`sentry`| Boolean | No |`-`| See enterprise docs. |
50
-
|`custom`| Boolean | No |`-`| See enterprise docs. |
|`loadAsync`| Boolean | No |`true`| Set if the script should be loaded asynchronously. |
37
+
|`cleanup`| Boolean | No |`true`| Remove script tag after setup. |
38
+
|`crossOrigin`| String | No |`-`| Set script cross origin attribute such as "anonymous". |
39
+
|`scriptSource`| String | No |`https://js.hcaptcha.com/1/api.js`| Set script source URI. Takes precedence over `secureApi`. |
40
+
|`scriptLocation`| HTMLElement | No |`document.head`| Location of where to append the script tag. Make sure to add it to an area that will persist to prevent loading multiple times in the same document view. |
41
+
|`secureApi`| Boolean | No |`false`| See enterprise docs. |
42
+
|`apihost`| String | No |`-`| See enterprise docs. |
43
+
|`assethost`| String | No |`-`| See enterprise docs. |
44
+
|`endpoint`| String | No |`-`| See enterprise docs. |
45
+
|`hl`| String | No |`-`| See enterprise docs. |
46
+
|`host`| String | No |`-`| See enterprise docs. |
47
+
|`imghost`| String | No |`-`| See enterprise docs. |
48
+
|`recaptchacompat`| String | No |`-`| See enterprise docs. |
49
+
|`reportapi`| String | No |`-`| See enterprise docs. |
50
+
|`sentry`| Boolean | No |`-`| See enterprise docs. |
51
+
|`custom`| Boolean | No |`-`| See enterprise docs. |
52
+
53
+
54
+
55
+
## Legacy Support
56
+
In order to support older browsers, a separate bundle is generated in which all ES6 code is compiled down to ES5 along with an optional polyfill bundle.
57
+
58
+
-`polyfills.js`: Provides polyfills for features not supported in older browsers.
59
+
-`index.es5.js`: **@hcaptcha/loader** package compiled for ES5 environments.
60
+
61
+
### Import Bundle(s)
62
+
Both bundles generated use IIFE format rather than a more modern import syntax such as `require` or `esm`.
63
+
64
+
```js
65
+
// Optional polyfill import
66
+
import'@hCaptcha/loader/dist/polyfills.js';
67
+
// ES5 version of hCaptcha Loader
68
+
import'@hCaptcha/loader/dist/index.es5.js';
69
+
70
+
hCaptchaLoader().then(function(hcaptcha) {
71
+
var element =document.createElement('div');
72
+
// hCaptcha API is ready
73
+
hcaptcha.render(element, {
74
+
sitekey:'YOUR_SITE_KEY',
75
+
// Additional options here
76
+
});
77
+
});
78
+
79
+
```
80
+
### TypeScript
81
+
To handle typescript with ES5 version, use the following statement.
82
+
```ts
83
+
declareglobal {
84
+
interfaceWindow {
85
+
hCaptchaLoader:any;
86
+
}
87
+
}
88
+
```
89
+
90
+
### CDN
91
+
The hCaptcha Loader targeted for older browsers can also be imported via CDN by using UNPKG](https://www.unpkg.com/), see example below.
0 commit comments