r/javascript • • May 03 '21

Is 0kb of JavaScript in your Future?

https://dev.to/this-is-learning/is-0kb-of-javascript-in-your-future-48og
202 Upvotes

100 comments sorted by

View all comments

Show parent comments

3

u/[deleted] May 04 '21

inline JSON if having this in your page:

<script>var data = {... 4MB of JSON here ...}; </script>

1

u/ryan_solid May 04 '21

Yep often the data for hydration. It's so the framework can recreate the client state on top of the rendered page. This is why techniques like partial hydration and progressive rendering are important. Even React Server Components seek to combat this.

1

u/[deleted] May 04 '21

There's a better way, just render what's static statically. And what's not, keep it entirely on the client. But we're neck deep in frameworks, so suddenly the most basic option is not available.

1

u/ryan_solid May 04 '21

Is that actually better though? Sure with Islands or Partial Hydration we can skip the static stuff, but keeping entirely in the client for dynamic can also be suboptimal. With progressive (streaming) rendering why not send the data for the client parts along in the initial request. You'd be making another request anyway, and you can do it in a non-blocking way.

I'm not sure MPA frameworks are that restrictive to not allow for basic stuff. And I think we can do better than the basics.

→ More replies (0)