And the reason for this increase is because the applications of today are a lot more interactive, lot more rich than they were 10, 20 years ago, and so we would expect that this particular trend would continue.
Now, unsurprisingly, I've picked a couple of frameworks on the left and show you what is their average performance that Google sees on the website. And on the right hand side, I'm showing you how much code these frameworks are shipping to the client. And notice that the frameworks that perform the best in terms of Lighthouse core also shipped the least amount of code. Again, this shouldn't be surprising because it basically tells you that, hey, the less code you ship, the easier it is for the browser to interpret it, execute it, and make the website interactive.
Now, the problem is that we need to ship code. We need to ship code in order to make the application interactive, and so we do this through this process called hydration. And the way hydration works is it starts with HTML, which essentially is a blank page first. And we'll talk about server-side rendering in a second. The JavaScript loads, the JavaScript then executes, then causes a rendering, and at this point, you actually have an actual interactive website. And it is at this point where you can go and click on it and perform operations.
Now, the problem is that we have this blank page at the very, very beginning, and so people started to do server-side prerendering. And so with server-side perendering, or SSR, or SSG, you end up with HTML, and the HTML now has a image that you can go and look at, but you can't really interact with it, right? And so there is an appearance of it being faster because the page actually appears faster for the user, and so that provides a better user experience. But it still has to download all of the JavaScript, it still has to execute all of the application, and it still has to render the application, except now we don't call that rendering. Instead we call it reconciliation, because we're trying to reuse as many DOM elements as possible inside of the UI. And so it is only at this point that the application becomes interactive. And notice what's actually happening, is that the interactivity is actually slower, have you said no content at the beginning at all. And so it's a bit of a dichotomy that we appear faster, but we're actually slower. And the reason for that is because we're actually sending more information, we're sending duplicate amounts of information. If you think about it, if you take a string, like visually built on your tech stack that you see in the image, that string actually appears twice. Once in HTML and once in JavaScript. And so this duplication actually means that you have to send more stuff to the client, the client has to process more stuff. And the end result is that there is a... that it takes longer for the application to wake up. Now, hydration, if you think about it, what it is, is that you start at a root component. And as this new root component gets processed and executed, hydration learned, the framework learns about other components, in this case, these three. And so it recursively goes and executes these components and learns about more components. And as it does so, it learns about the listeners. And it's the listeners that we actually care about. Listeners, state, and the boundaries of the components is the information that we need in order to make the application interactive.
Comments