@hcaptcha/vanilla-hcaptcha
Version:
Vanilla Web Component for hCaptcha. 0 dependencies. <1kb gzipped.
19 lines (18 loc) • 687 B
TypeScript
import { VanillaHCaptchaJsApiConfig } from "./hcaptcha";
declare global {
interface Window {
_hCaptchaOnLoad?: Function;
_hCaptchaOnLoadPromise?: Promise<void>;
}
}
/**
* Loads the hCaptcha JS API only once on the page despite multiple attempts.
*
* Usage:
* 1. import hcaptchaScript from './hcaptcha-script';
* 2. when web component is mounted do:
* loadJsApiIfNotAlready(HCaptchaConfig)
* .then(() => console.log('hcaptcha is loaded, so it is safe to be used'))
* .catch((err) => console.error('failed to load the hcaptcha', err));
*/
export declare function loadJsApiIfNotAlready(config: VanillaHCaptchaJsApiConfig): Promise<void>;