hunghvu / hungvu.tech

The official repository for hungvu.tech
https://hungvu.tech
3 stars 0 forks source link

Blog/home page: Improve core web vitals #99

Closed hunghvu closed 10 months ago

hunghvu commented 10 months ago

image

image

image

image

image

image

hunghvu commented 10 months ago

Note, that due to #91 and #92, the layout was substantially changed. Although the measurement is different, the core idea of this ticket remains. The pictures below is from running next start on local next build.

FCP image

LCP image image image image

TBT image image image

CLS image

hunghvu commented 10 months ago

With 35d936, it shifts the LCP measurement to this.

image

hunghvu commented 10 months ago

It might not be trivial to improve FCP in appDir:

hunghvu commented 10 months ago

If we can optimize the import of CSS, then hljs (CSS + JS), perhaps LCP will decrease. Or is it simply due to sheer length and need lazy loading?

hunghvu commented 10 months ago

If it is not trivial to add inline critical CSS, then we can consider purging (PurgeCSS) or minifying CSS (CSS Nano).

CSS Nano does not seems to work with Next.js, because CSS Nano is internally used by Next.js (big question mark? Only applied to .module.css?)

hunghvu commented 10 months ago

Two points to think about.

hunghvu commented 10 months ago

In fd4c940, it seems either due to @tailwind resides in layers, or due to misconfiguration because tailwind.config.js resides in another package (path issue?), Tailwind JIT does not work. This causes all Tailwind CSS are delivered to production, causing a large amount of unused CSS bytes.

Besides, removing PrimeReact node_modules from tailwind config content did something. In short,

hunghvu commented 10 months ago

We will go ahead and finish the optimization process here. There are still 2 unresolved issues, which will be for future tasks.