-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Duplicate head
elements occur when html comments are stripped
#8112
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
Comments
I just found out that I'm a victim of this too. It's a really nasty "bug" because like you mentioned it went unnoticed for a long time. I had to turn off cloudflare HTML auto minify (Credits to you) |
It sure would be great if this sneaky bug was fixed! |
I'm noticing this issue too. It's causing a problem with my theme system as if the user changes their theme, the head element is not being correctly updated to remove the old stylesheet when the new one is included. This leads to both stylesheets being active at the same time, and has created an annoying difference between development and production builds. |
+1 |
2 similar comments
+1 |
+1 |
+1 Upgrading svelte version, disabling HTML compression from Cloudflare doesn't helped my project. The svelte:head duplication's issue still persists on some of the SSR pages and not in all pages which is quite weird even though in local which doesn't even use cloudflare :/ Is anyone here has seen this issue as really fixed? |
My temporarily fix: OnlySSR.svelte
Page.svelte
|
I had the same issue with the latest svelte version (4.2.12) even on local host in dev mode. SSR was also not working for the meta tags so the above work around did not solve my issue. The root of my issue was that several of my components, which were incorporated within Cleaning up the components to remove the nesting of |
I forgot to mention that I am using the Anyway I noticed that the tag title is not duplicating and left me confused. That's why I chose to create a component to handle this. |
Svelte's hydration mechanism is heavily relying on comments, stripping them out will break things. The minifier should be adjusted such that it doesn't strip comments. Therefore closing. |
+1 |
Describe the bug
The solution to the duplicate content
svelte:head
element bug (and also this one) requires HTML comments to be present in order to function correctly. Many minification tools strip HTML comments, and as does CloudFlare by default in many environments.Duplicating the
head
element is a fairly insidious bug because it isn't immediately obvious that anything is wrong, but for our project (in SvelteKit) it decreased performance by loading analytics scripts multiple times. We also suspect that it may have broken some web indexing, but couldn't be sure.If there is a better way to solve this than relying on comments, that would be great. I've marked the
Severity
asannoyance
, but only because we have found a highly unsatisfactory workaround that I would rather not have in place long term.Reproduction
One straightforward way to reproduce this would be to use the reproduction repo provided in this issue, which minifies the html response and strips comments: when comments are stripped, the duplicate header bug is present.
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: