So, we found that we could do this in Nuxt. We could inline them. So, we take a component like this, which this is a Vue component. If you haven't come across it, think of it as a bit of HTML, a bit of CSS, a bit of JavaScript. In this case, it's just HTML and CSS. So, we take that CSS. We take that component, we track it. So, this is what it compiles into with a Vue compiler. We're able, every time that component is loaded or renders something on the server, we track what component was loaded or what component managed to render something. Then we're able to take that key and track it with the styles that it had. So, this is something that we do. This is our actual code that we run. And we take all of the styles of that component and then every component that rendered on the server, and we smush them into one single inlined style block that we can actually render on the initial load. We remove everything from the client-side CSS that we're guaranteed will be in the server rendered HTML. And, hey presto, what we should have is more performant websites. There's a cost, of course. Every time you do that, you reduce the cacheability of your CSS, so it's not simply one file. But on the other hand, you have very performant, low layout shift on the initial load. You reduce the number of files that you download. And we think, in general, that is a good default, particularly for Vue components, which are often chunked. So they produce separate files. And we are very well able to track them. In fact, on the flight coming over, I was just implementing this feature. We shipped with it for Vite in Nuxt 3 and 4, but I was just implementing it for Webpack and RSPack. So we should expand that in Nuxt pretty soon.
Here's the second thing that we're doing. I don't know what your favorite core web vital is. I assume we all have favorite core web vitals, right? The poster in the office of your favorite core web vital? No? It's just me? So one of the new core web vitals that came in just in the last couple of years is interactionToNextPaint, I-N-P, which basically measures the response time when you perform any kind of interaction on a website. How quickly does it respond to what you've done? And one of the big warnings that came out, this was actually tweeted by someone on the Chrome team, who spotted that actually of quite a lot of frameworks, when this new core of vitals came out, they would see huge decreases in their website performance results for websites that were using those frameworks. And we found out that this was true for Nuxt.
Comments