Skip to content

Hydration markers cause increase in document sizeΒ #14099

@khromov

Description

@khromov

Describe the problem

The new hydration markers in Svelte 5 increases output size and causes messy HTML output. This leads to increased bandwidth and processing costs for the payloads.

Repro:
https://github.com/khromov/hydration-markers-sveltekit-repro

Run npm run build && npm preview

Increase in document size

We compare the HTML output of a short text formatted using the Stylizr library:

Screenshot 2024-11-01 at 13 39 41

With gzip disabled, the document is 2.8KB

Screenshot 2024-11-01 at 13 33 37

With gzip enabled, the document is 1.9KB.

Screenshot 2024-11-01 at 13 34 20

We can compare it with a baseline where we removed the formatting, in this case gzip disabled is 2.3KB and gzip enabled is 1.8KB. It seems like gzip does remove the brunt of the additional size, but the size of the uncompressed payload is markedly increased by the hydration markers.

Messy HTML

Every time a formatting is applied a new component (technically Snippet) is added to the output. The result lead to very messy HTML output with hydration markers:

Screenshot 2024-10-31 at 16 54 00

Describe the proposed solution

The components/snippets in the repro don't have any reactive props, it is just static text. If this case could be detected, perhaps hydration markers could be removed?

Importance

would make my life easier

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions