Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate Script Injection in Head Tag When Using ngx-turnstile Component #29

Closed
khaperets opened this issue Jul 3, 2024 · 2 comments · Fixed by #31
Closed

Duplicate Script Injection in Head Tag When Using ngx-turnstile Component #29

khaperets opened this issue Jul 3, 2024 · 2 comments · Fixed by #31
Assignees

Comments

@khaperets
Copy link

Every time the ngx-turnstile component is used, a script tag is added to the head section of the HTML. This leads to multiple script tags being injected, which can cause performance issues and potential conflicts.

Reproduction Steps:

  1. Add the ngx-turnstile component to a page or component.
  2. Inspect the head section of the HTML document.
  3. Observe the script tag:
    <script src="https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit&amp;onload=onloadTurnstileCallback" async="" defer=""></script>
  4. Navigate to another page or component where ngx-turnstile is used.
  5. Inspect the head section again and notice the duplication of the script tag.

Expected Behavior:
The script tag should be added to the head section only once, regardless of how many times the ngx-turnstile component is used.

Actual Behavior:
Each use of the ngx-turnstile component results in an additional script tag being injected into the head section.

Possible Solution:
Implement a check to ensure the script is only added once to the head section, regardless of how many times the ngx-turnstile component is instantiated.

Error in console:
[Cloudflare Turnstile] Turnstile already has been loaded. Was Turnstile imported multiple times?.

@AleksanderBodurri
Copy link
Contributor

Thanks for reporting this @khaperets. Will cut a release later today with the fix from #31

@khaperets
Copy link
Author

Thanks!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants