Easily load and reset Cloudflare Turnstile when an element (div/span) appears. For example, when success element is shown, reset Cloudflare Turnstile.
The purpose of this script is to handle the situation where you want to reset Cloudflare Turnstile after a contact form was submitted, so that someone could submit the form again without having to reload the page.
- Loads Cloudflare Turnstile dynamically (only import this
turnstile.js
script in your main HTML) without the need to import it on a separate line - Waits until the
triggerWhenVisibleSelector
becomes visible - Resets Cloudflare Turnstile so it can be used again