-
Notifications
You must be signed in to change notification settings - Fork 537
Optimize page data size and parsing (37% size reduction!) #2687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
@pascalbaljet it would be greatly appreciated if you could take a look at this and review, it would lead to a decent performance improvement for SSR and also a payload size reduction. |
|
Awesome! I'll look into this soon. |
|
And if the TOON format https://github.com/toon-format/toon could be used, I think it would be even lighter. |
|
Seems unsuitable, they themselves say that non uniform and deeply nested JSON is more efficient if that is required, and since Inertia props tend to fall into those criteria, let's just stick with a native browser API. No need to overcomplicate things. |
|
I'll refactor it a bit to put it behind a configuration flag. While it's backwards compatible, there's a possibility that people are relying on the |
|
That makes sense. Thanks! Looks good already. |
|
Do you need anything from me still, @pascalbaljet? |
No, thanks! I'll work some more on this by adding tests, and then I'll merge it. |
This PR adds support for the page data to be loaded from an
app_page<script type="application/json">element, this saves the SSR daemon quite a lot of type on big payloads because it not longer has to escape the HTML using"in the JSON.It also saves a lot of page size on big payloads.
One of our pages with currently 343kb in props, went down to 219kb using this patch. That is a 37% reduction!
I have tested the changes using the SSR setup in the playgrounds. The changes are also backwards compatible, because the code gracefully falls back to using the
data-pageattribute.In our profiler dump for the Node SSR process, escapeHtml takes up a non-insignificant of the profile with big payloads:
Inspired by my colleague @thomas-brx: #1960
Screenshots from the playgrounds working, note the
app_pageelement:Vue
Svelte
React