Skip to content

perf(core): provide initial state as one JSON document - #66244

Open
susnux wants to merge 1 commit into
masterfrom
feat/initial-state-json
Open

susnux wants to merge 1 commit into
masterfrom
feat/initial-state-json

Conversation

@susnux

@susnux susnux commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Render all initial states as a single <script type="application/json"> grouped by app and key instead of one base64 encoded hidden input per key. This removes the base64 overhead (30-60 % bigger after compression) and renders about 6x faster on the server.

The new core-initial-state entry is loaded before every other script and installs an InitialStateMap as window._nc_initial_state. It parses the JSON on first access and indexes the values by the #initial-state-<app>-<key> keys that @nextcloud/initial-state 3.x looks up there, so apps using 3.x keep working unchanged. It also provides hasState() and getState() for future library versions.

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

Render all initial states as a single `<script type="application/json">`
grouped by app and key instead of one base64 encoded hidden input per
key. This removes the base64 overhead (30-60 % bigger after compression)
and renders about 6x faster on the server.

The new `core-initial-state` entry is loaded before every other script
and installs an `InitialStateMap` as `window._nc_initial_state`. It
parses the JSON on first access and indexes the values by the
`#initial-state-<app>-<key>` keys that `@nextcloud/initial-state` 3.x
looks up there, so apps using 3.x keep working unchanged. It also
provides `hasState()` and `getState()` for future library versions.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
@susnux susnux added this to the Nextcloud 36 milestone Nov 3, 2026
@susnux
susnux marked this pull request as ready for review November 4, 2026 10:59
@susnux
susnux requested review from a team as code owners November 4, 2026 10:59
Comment thread core/templates/layout.initial-state.php Resolved

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants