UNPKG

@wojtekmaj/react-recaptcha-v3

Version:

Integrate Google reCAPTCHA v3 with your React app

23 lines (19 loc) 535 B
import type { ScriptProps } from './types.js'; export function loadScript({ async, appendTo, defer, id, nonce, src }: ScriptProps) { const script = document.createElement('script'); if (async !== undefined) { script.async = async; } if (defer !== undefined) { script.defer = defer; } if (id) { script.id = id; } if (nonce) { script.setAttribute('nonce', nonce); } script.src = src; const appendTarget = appendTo === 'head' ? document.head : document.body; appendTarget.appendChild(script); }