You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a message is pre-rendered (SSG or SSR), there is no need to ship the message to the client, if the message is static (takes no arguments). See #88 (comment)
// happy_elephant = This is a message in English. <p>{m.happy_elephant()}</p>
The HTML is rendered as
<p>This is a message in English</p>
Given that the message is static (takes no arguments like username), there is no need to ship the message function to the client. The message will aways be This is a message in English
Proposal
Figure out how to avoid shipping static messages that are pre-rendered to the client.
The text was updated successfully, but these errors were encountered:
The client needs the message for client-side hydration. I have to look into frameworks to see if replacing the expression <p>{m.foo()}</p> with <p></p> will make hydration work because frameworks skip over empty HTML tags. The server would SSR <p></p> as <p>example text</p>
In any case, research in #425 has shown that MPAs (Server side rendering + client side routing like SvelteKit) need to receive the message over the network to render pages.
I dug into a front-end framework to see how they hydrate. Svelte hydrates the HTML by completely re-rendering it even if the text of an HTML node is static.
<p>Hello world, how are you?</p>
import { a as append, t as template } from "../chunks/C2OGyoPZ.js";
import "../chunks/DmGnqJ7V.js";
+var root = template(`<p>Hello world, how are you?</p>`);
function _page($$anchor) {
var p = root();
append($$anchor, p);
}
export {
_page as component
};
This indicates that even if we optimize messages to be static via an AST transform in a bundler, the optimization has no effect because frameworks load the static text anyways.
In a NextJS project with RSC, no JS is shipped to the client, which makes this optimization redundant and is the first time I understand RSC's value.
What's next? Frameworks need to optimize this themselves it seems like
Context
If a message is pre-rendered (SSG or SSR), there is no need to ship the message to the client, if the message is static (takes no arguments). See #88 (comment)
The HTML is rendered as
Given that the message is static (takes no arguments like username), there is no need to ship the message function to the client. The message will aways be
This is a message in English
Proposal
Figure out how to avoid shipping static messages that are pre-rendered to the client.
The text was updated successfully, but these errors were encountered: