Skip to content

Improve script loading when streaming is enabled #31338

Closed
@shuding

Description

@shuding

Describe the feature you'd like to request

A while ago we changed the default script loading strategy to use defer in #24939. However this doesn’t work well within the streaming model since deferred scripts will only be executed after finishing the full HTML. This makes selective hydration kinda useless because there is no way to hydrate early.

Describe the solution you'd like

That said, it would be great to switch back to the async strategy for the runtime and modules when concurrentFeatures is enabled, and leverage the bootstrapScripts option (facebook/react#22594) to inject them at the right time.

And finally, a <link rel=preload> tag might also be necessary to maximize performance.

Describe alternatives you've considered

As a workaround, you can also use the disableOptimizedLoading flag to manually switch back to the async strategy. But it can’t start hydration with the perfect timing.

Metadata

Metadata

Assignees

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