As commenters said - there is no way to make parsing faster.
If the concern is that the app is blocked while it's stringifying/parsing then try to split data into separate objects, stringily them and assemble back into one object before saving on the server.
If loading time of the app is not a problem you could try to ad-hoc incremental change on top of the existing app.
- ... App loading
- Load map data
- Make full copy of the data
- ... End loading
- ... App working without changes
- ... When saving changes
- diff copy with changed data to get JSON diff
- send changes (much smaller then full data)
- ... On server
- apply JSON diff changes on the server to the full data stored on server
- save changed data
I used json-diff https://github.com/andreyvit/json-diff to calc changes, and there are few analogs.
Answer from Wlodzislav K. on Stack OverflowAs commenters said - there is no way to make parsing faster.
If the concern is that the app is blocked while it's stringifying/parsing then try to split data into separate objects, stringily them and assemble back into one object before saving on the server.
If loading time of the app is not a problem you could try to ad-hoc incremental change on top of the existing app.
- ... App loading
- Load map data
- Make full copy of the data
- ... End loading
- ... App working without changes
- ... When saving changes
- diff copy with changed data to get JSON diff
- send changes (much smaller then full data)
- ... On server
- apply JSON diff changes on the server to the full data stored on server
- save changed data
I used json-diff https://github.com/andreyvit/json-diff to calc changes, and there are few analogs.
Parsing is a slow process. If what you want is to POST a 10MB object, turn it into a file, a blob, or a buffer. Send that file/blob/buffer using formdata instead of application/json and application/x-www-form-urlencoded.
Reference
An example using express/multer
Videos
You shouldn't use SessionStorage for that purpose because it is blocking main thread that can leads to hanging your application.
Check IndexedDb instead
It designed to be async and more-less fast. And also it has pretty nice support:
https://caniuse.com/#search=indexeddb
Hope this helps
As @IrkenInvader said test and measure on your reference browser(eg. on low end mobile device parsing can be much slower).
A quick test:
function getRandomInt(max) {
return Math.floor(Math.random() * Math.floor(max));
}
var numbers = Array.apply(null, {length: 10000}).map(Function.call, (x) => getRandomInt(100));
var start = window.performance.now();
window.sessionStorage.setItem('test', JSON.stringify(numbers));
var end = window.performance.now();
console.log("timing", end-start);
» npm install fast-json-stringify
I faced with issue during testing performance. Full post there r/ifjsdoes