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

Script does not execute in Firefox upon consent #9

Closed
bent-rasmussen opened this issue Jun 13, 2022 · 3 comments
Closed

Script does not execute in Firefox upon consent #9

bent-rasmussen opened this issue Jun 13, 2022 · 3 comments

Comments

@bent-rasmussen
Copy link

bent-rasmussen commented Jun 13, 2022

I have integrated your component and tested it in our solution. I quickly ran into the script tag should have the defer attribute set, otherwise Blazor seems to strip out the script tag from head of the server rendered HTML (.NET Core 6 Blazor - server rendered); I am writing this this since it is not clear from your otherwise excellent documentation (but maybe there is another way to handle this I am not aware of).

Once that was done I tested in Microsoft Edge and it seems to work well. I can see the script tag is changed to text/javascript and there is network traffic accessing a Google analytics resource.

However, the same is not true in Firefox (only have 1 add-on installed and it is disabled; also with all blocking turned off in settings). I can observe the cookie is created in Firefox and the script tag is changed when I consent - but the Javascript for the Google analytics tag does not seem to do anything - i.e. no network traffic.

You can check this yourself by just adding this code to the head of the page:

<script type="text/plain" data-consent-category="google" defer="defer">
      alert("google consent detected - but not in Firefox");
</script>

In Edge the alert will show; in Firefox it will not.

@RyanTT
Copy link
Member

RyanTT commented Jun 14, 2022

Hello and thank you for the feedback!

I personally wasn't aware that the defer attribute is required, I will add it to the documentation.

I attempted to address the issue you described about Firefox not executing the script tag in 95af524.
The fix is published as a preview package on nuget, please let me know if this resolves the issue for you.

@bent-rasmussen
Copy link
Author

Your changes seems to have fixed the issue! At least I cannot find anything else wrong with it. Much appreciated, since this looks like the nicest cookie consent solution I could find for Blazor. 🙏

If you had a Github donate option, I would donate. Thanks again!

@RyanTT
Copy link
Member

RyanTT commented Jun 15, 2022

Glad the issue is fixed. I will publish the preview package as a stable package later today 👍

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

No branches or pull requests

2 participants