perf: optimize Cloudflare Turnstile CAPTCHA loading on login#477
Merged
perf: optimize Cloudflare Turnstile CAPTCHA loading on login#477
Conversation
Add preconnect hint for challenges.cloudflare.com to start DNS/TCP/TLS early, and switch Turnstile to interaction-only mode so the widget is invisible unless Cloudflare needs human interaction. Handle early form submissions by deferring until the token is ready.
There was a problem hiding this comment.
Pull request overview
Optimizes Cloudflare Turnstile integration in Twig templates by reducing perceived latency and minimizing widget UI on user-facing forms.
Changes:
- Updates the Turnstile widget to
interaction-onlymode and adds client-side submit deferral until a token is available. - Adds a
preconnecthint forchallenges.cloudflare.comto warm up DNS/TCP/TLS earlier.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| templates/captcha.html.twig | Switches Turnstile configuration and adds JS to delay form submission until CAPTCHA completes. |
| templates/base.html.twig | Adds a global preconnect hint for Cloudflare Turnstile’s domain. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
<link rel="preconnect">forchallenges.cloudflare.cominbase.html.twigto save ~200-500ms on DNS/TCP/TLSinteraction-onlymode — widget is invisible unless Cloudflare needs human interaction, eliminating the visible "waiting for CAPTCHA" delayTest plan
/logovanje(not logged in), confirm no visible CAPTCHA widget appearschallenges.cloudflare.comis present/registracija-donatoraand/postani-delegat