Description
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
as annoyance
, 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
System:
OS: macOS 12.6
CPU: (10) arm64 Apple M1 Pro
Memory: 90.36 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.15.1 - ~/.nvm/versions/node/v16.15.1/bin/node
npm: 8.11.0 - ~/.nvm/versions/node/v16.15.1/bin/npm
Browsers:
Chrome: 108.0.5359.98
Firefox: 105.0.2
Safari: 16.1
npmPackages:
svelte: ^3.55.0 => 3.55.0
Severity
annoyance