Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blog/home page: Improve core web vitals #99

Closed
hunghvu opened this issue Dec 24, 2023 · 8 comments
Closed

Blog/home page: Improve core web vitals #99

hunghvu opened this issue Dec 24, 2023 · 8 comments
Labels
performance web Related to the web service
Milestone

Comments

@hunghvu
Copy link
Owner

hunghvu commented Dec 24, 2023

  • First contentful paint (FCP)
    • Avoid chaining critical request

image

  • Largest contentful paint (LCP)
    • Hight time to first byte (TTFB) and render delay.

image

image

image

image

image

@hunghvu hunghvu added web Related to the web service performance labels Dec 24, 2023
@hunghvu hunghvu added this to the 1.1 milestone Dec 24, 2023
@hunghvu
Copy link
Owner Author

hunghvu commented Dec 26, 2023

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 added a commit that referenced this issue Dec 26, 2023
@hunghvu
Copy link
Owner Author

hunghvu commented Dec 26, 2023

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

image

@hunghvu
Copy link
Owner Author

hunghvu commented Dec 26, 2023

@hunghvu
Copy link
Owner Author

hunghvu commented Dec 26, 2023

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
Copy link
Owner Author

hunghvu commented Dec 27, 2023

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
Copy link
Owner Author

hunghvu commented Dec 28, 2023

Two points to think about.

  • Why is LCP still high even with server components?
  • How to reduce unused bytes?
    image

hunghvu added a commit that referenced this issue Dec 29, 2023
…ion between PrimeReact and Tailwind, related to #99
@hunghvu
Copy link
Owner Author

hunghvu commented Dec 29, 2023

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,

  • Before the change: Total size 64k, unused 27k
  • After change, with PrimeReact node_modules included: Total size 64k, unused 58k (?)
  • After change, with PrimeReact node_modules remove: Total size 12k, unused 4k!!

@hunghvu
Copy link
Owner Author

hunghvu commented Dec 30, 2023

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

  • High LCP, especially render delay. It seems impossible to remove that even when we have only a barebone Next.js application, or is there some misconfiguration?
  • Inline critical CSS, no official support for app router, leading to blocking render requests (CSS).

@hunghvu hunghvu closed this as completed Dec 30, 2023
hunghvu added a commit that referenced this issue Dec 30, 2023
* chore: bump packages

* chore: mark development tasks as no-cache and non-persistent

* chore: bump packages

* feat: add self-host container for mongodb, relates to #93

* feat: expose containers to only localhost (#94)

* feat: optimize indexes to improve performance, relates to #93

* feat: closes #78, enable AVIF image support

* chore: change some parameters to improve experience in development environement

* fix: closes #88, prevent long string overflows

* feat: use animated SVG background, related to #92

* feat: closes #92, overhaul article page UI to improve accessibility and make theme suitable with animated background

* fix: closes #84, increase line height

* fix: closes #89, make letters start at the same place in ordered list, and align ol with ul

* feat: closes #91, overhaul blog page UI and make it SSR

* chore: bump packages

* chore: bump Geist font to v1.2.0, and rename files

* fix: closes #101, now code snippet uses GeistMono font

* feat: load SVG background via next/image to utilize optimization (preload LCP), related to #99

* feat: enforce cache-control on Next.js, relates to #98

* feat: minimize highlight.js import, and change CSS import location, related to #99

* feat: disable external page prefetch, related to #99

* fix: bundle public folder in production

* fix: closes #102, CSS layer order issue

* feat: make divider appear on lg screen and make it dimmer

* feat: adjust navbar color and border to further emphasize articles

* feat: multiple adjusment to text and border, divider color to increase separation and readability

* fix: closes #103, make toast message bottom-center, and remove white border

* feat: adjust font size to improve readability

* feat: remove primeicons to reduce bundle size (blocking and unused CSS), related to #99

* chore: bump packages

* fix: disable AVIF support in an attempt to resolve #105

* fix: remove redundant scrollbar in main page

* feat: use native browser scroll to reduce bundled JS size, related to #99

* feat: massively remove unused CSS bytes by reconfiguring the interaction between PrimeReact and Tailwind, related to #99
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance web Related to the web service
Projects
None yet
Development

No branches or pull requests

1 participant