Faster serialization / deserialization of object data in Javascript?

Viewed 199

I'm doing server-side rendering using and React/Redux.

To pass Redux data to the front end, I'm serializing it to JSON in a script tag thats hydrated on the client in the head:

<script>window.INITIAL_REDUX_STATE=${JSON.stringify(store.getState())};</script>

Some problems with this:

  • the state is extremely large (unfortunately "just make it smaller" isn't a solution), meaning the client has to download a significant amount of data

  • de-serialization time on the client is non-trivial

  • since its in a script tag, the browser blocks waiting for it to load. Some of this is unavoidable since the state impacts the UI

Is there a faster and/or more compact way to serialize and re-serialize Javascript object hierarchy (blobs, proto-buffs, etc) that fits this use-case?

0 Answers
Related