nuxt-modules / turnstile

đŸ”Ĩ Cloudflare Turnstile integration for Nuxt
https://cloudflare.com/products/turnstile
MIT License
215 stars 17 forks source link

perf: load script only on pages where it is used #288

Open avi-agg opened 6 months ago

avi-agg commented 6 months ago

📚 Is your documentation request related to a problem?

By default the Script is being loaded on all pages. I want it to load on selected pages. How can I do that?,

🔍 Where should you find it?

No response

ℹī¸ Additional context

No response

dargmuesli commented 6 months ago

I think the plugin's functionality to load the script would need to be moved to the NuxtTurnstile component. Before I say "pull request welcome" though, I'd like to ask @danielroe if there is any reason to keep the head extension in the plugin.

danielroe commented 6 months ago

Yes, I think it would be nice to move it to the component, if we can implement it so it's deduplicated across components and also not removed from the head if the component is unmounted (as this could result in the script being loaded more than once).

avi-agg commented 6 months ago

That's great to hear... Can you create a pull request for it?

lucasuracosta commented 6 months ago

+1

dargmuesli commented 6 months ago

I think this is a good task for a community PR, help welcome! :raised_hands: