Skip to content

Start: SSR dehydrated script output contains unnecessary whitespace/newlines #6947

@canmi21

Description

@canmi21

Which project does this relate to?

Start

Describe the bug

The inline <script> blocks generated by TanStack Start for SSR dehydration contain unnecessary blank lines and whitespace. Since this output is machine-generated serialization (Seroval streams, router state, etc.) and not user content, it could be minified without any risk of breaking functionality.

Your Example Website or App

https://github.com/canmi21/taki

Steps to Reproduce the Bug or Issue

View the HTML source of any SSR-rendered TanStack Start page. The dehydrated <script> tags contain patterns like:

<script>($R=>{ ... })($R["tsr"]);    
 document.currentScript.remove()</script>
Image

There are blank lines between statements and unnecessary newlines within the Seroval stream constructor output.

Expected behavior

Dehydrated script output should be compact, e.g:

 <script>($R=>{ ... })($R["tsr"]);document.currentScript.remove()</script>

Screenshots or Videos

Image

Platform

  • Router / Start Version: 1.166.11
  • OS: any
  • Browser: any
  • Browser Version: any
  • Bundler: vite
  • Bundler Version: 8.0.0

Additional context

Why this matters

Slightly increases HTML payload size on every SSR response before compression Makes View Source unnecessarily noisy
This is framework-generated serialization, not user-authored content there is no "<pre.>" or whitespace-sensitive context to worry about, so it is safe to strip

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