开发者

Deserialize big data JSON from a REST request into objects without locking up the browser?

开发者 https://www.devze.com 2023-04-12 17:41 出处:网络
In a rich internet app: User requests a resource Server responds with a huge JSON response Client (running in browser) must process the JSON converting it to the many objects which make up the appli

In a rich internet app:

  1. User requests a resource
  2. Server responds with a huge JSON response
  3. Client (running in browser) must process the JSON converting it to the many objects which make up the application state.

Step 3 is intensive and can cause the browser to lock. I was thinking about using web workers but I think they may not be suited for the task.

As I understand workers, they pass messages purely as text or JSON. So while it would be possible for the web worker to accept a message ("please fetch the resource at this URL") the worker could then retrieve the large JSON response and even deserialize it into the many objects making up the app state, but there would be no way to pass objects (instances of various classes) back to the main process via the message passing construct. Right? Or am I missing something?

How would one allow an in-browser client to deserialize big da开发者_Go百科ta into objects without compromising the user experience (locking the browser)? If web workers are out, does that leave using timers (for timeslicing)?


How JavaScript is Slowing Down the Web (And What To Do About It)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号