Remix.run Logo
8n4vidtmkvmk 3 days ago

For first load, yes. The idea is that you never have to send the template again after that.

Cascading is a separate problem. You can bundle all the data into a single request if you want.

You can even send JSON along with the HTML in the first request.

hasanhaja 3 days ago | parent | next [-]

Why does this have to be the baseline architecture when you can render the HTML on the server with the template and data? Why send the data and the JavaScript to parse that data and transform it into HTML in a users browser when you can do it on the server?

For requests after the first, you can still continue to send the rendered HTML to be placed into the document. Here's an example using HTMX: https://htmx.org/examples/lazy-load/

8n4vidtmkvmk 2 days ago | parent [-]

If your app is simple enough, go ahead and do that. In nearly every app I've worked on, I eventually need some dynamic piece of content. Like even a date picker, so you really want to call the server every time the use wants to go to the next month?

wild_egg 2 days ago | parent [-]

Why on earth would you drive a date picker from the server? No one is saying to do that. JS is absolutely fine to build custom UI controls. The form the date picker renders in doesn't need to be 100% JS though.

Use JS to patch over things the browser doesn't implement and let it handle the rest.

8n4vidtmkvmk a day ago | parent [-]

Ok, at least we agree on something. I think that's fine if your app is simple enough, but the more and more dynamic it gets, at a certain point, I think it makes sense to just render the whole darn thing in JS. At least for the DX.

wild_egg 3 days ago | parent | prev [-]

> The idea is that you never have to send the template again after that.

This implies or assumes that sending the template again is a problem. In practice, it's not. HTML compresses well and the difference between the compressed JSON and HTML response is often on the order of hundreds of bytes. That assumes equivalent data content which, as I've said above, is often not the case. JSON payloads tend to be larger and we need more of them to render the same UI.