Skip to content

React SSR performance #572

Closed
Closed

Description

@NikSimonov

Environment

nodes 22.18.0
react 19.1.1
unhead 2.0.14

Reproduction

if you tell me the best way to generate useful performance reproduction I'll gladly do it

Describe the bug

we have fairly old school webpack react app, did migration from react-helmet to unhead according to migration guide, deployed it on prod and detected substantial latency increase for our ssr rendering (p50 90 to 160 ms). I don't know how unhead differs from react-helmet in terms of collecting tags, but I guess culprit is something in transformHtmlTemplate

Image

Additional context

No response

Logs

Activity

  1. harlan-zw commented on Sep 18, 2025

    @harlan-zw
    Collaborator

    Thank you for this important issue and visibility on the performance.

    You were right to suspect transformHtmlTemplate, this was the culprit, and further details are in #581.

    Can you please try v2.0.15 and let me know how the performance improves? For large HTML pages, it should be about 10x faster.

    I've also introduced transformHtmlTemplateRaw, it has the same signature but skips any pre-processing of the HTML. This is useful if you know the HTML will be pure (i.e not include possible duplicates & not include tags that need to be in a specific spot). Feel free to give it a try, I'll properly document it if it proves to be stable enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions