SSR: Why are page props output as json inside <script type="application/json" sveltekit:data-type="props">
instead of the hydrate script?
#4899
Unanswered
UltraCakeBakery
asked this question in
Q&A
Replies: 2 comments 1 reply
-
I don't know the specific reasons for it, but I wouldn't be surprised if it was due to prior art or previous attempts at serializing more arbitrary objects (eg. in Sapper). While it'd be possible to move it to the script tag, we'd actually gain very little:
Having said all that, I wouldn't be against it, but maybe there were more important reasons for the tag approach I'm not aware of. |
Beta Was this translation helpful? Give feedback.
0 replies
-
It's primarily for performance reasons: https://www.bram.us/2019/11/25/faster-javascript-apps-with-json-parse/ |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I do not understand the reason that svelte-kit includes page props separate script tag as a json string, instead of it being included as a javascript object in the hydrate script tag or as a global constant available tot the page. Would that not be more compress-able and easier to access in the case you need it?
Beta Was this translation helpful? Give feedback.
All reactions