-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Use JSON to pass data from SSR to improve performance #6168
Comments
What about circulair references? Or types which are not supported by JSON? |
For circular references we have: https://github.com/WebReflection/circular-json For unsupported JSON types could you elaborate a little bit more? What's the usecase? |
@manniL could you unveil these reasons if possible? I'm really curious when JSON is not appropriate as a DTO. |
circular-json seems to be replaced by flatted. I tested flatted and devalue on 120kb payload. Without circular. repeated references ([value, value]) For example undefined values just got stripped by json.stringify |
@aldarund how about use json.strigify(value, function(key,value){ xxxx }) instead devalue; |
Just for information, I notice the same type of performance issue with, for example, the script injection in vue-renderer :
In my case, with devalue, ~10ms, with JSON.stringify, ~1ms. |
This is now implemented in Nuxt 3. |
What problem does this feature solve?
Using JavaScript to pass data from SSR to an app through global context is not efficient.
JSON, on the other hand, offers a much better performance and could be used instead. Explanation in v8 blog, Benchmarks (performance increase up to 2 times)
This is especially important for apps with a lot of state.
What does the proposed changes look like?
This code:
Turns into this:
The text was updated successfully, but these errors were encountered: