Skip to content

Redirect from prerendered pages with <script> #9907

Closed
@Rich-Harris

Description

@Rich-Harris

Describe the problem

When prerendering, if we encounter a redirect it gets baked out as an HTML file with a <meta> refresh tag:

writeFileSync(
dest,
`<meta http-equiv="refresh" content=${escape_html_attr(`0;url=${location}`)}>`
);

Turns out (h/t @cramforce) it's actually quicker to use a <script>:

<script>onload=() => location.href = "${url}"</script>

(Do we even need the onload? Would it be quicker still without it?)

Describe the proposed solution

Do both — <script> for speed, <meta> for reliability.

Alternatives considered

No response

Importance

nice to have

Additional Information

No response

Metadata

Metadata

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