-
Notifications
You must be signed in to change notification settings - Fork 253
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
feat: experimental lcp hints in development mode #763
Conversation
👷 Deploy request for nuxt-image pending review.Visit the deploys page to approve it
|
A few ideas:
|
Nice idea! Personally, I would say that these types of general performance warnings would be better suited in their own module, or possibly the web vitals module. If the intent is to have LCP images created correctly, then maybe there's scope to add a new component in the @nuxt/image module that handles it:
Couple of thoughts on your code:
|
Thanks for the feedback @manniL @harlan-zw Alex:
Harlan: I have been thinking initially to have these hints as a part of web vitals or nuxt-performance module but I eventually decided to go for Image module hints instead. Let me explain my decision. Web Vitals alreadh gives similr functionality as you are getting an onLCP with the value and the element. These hints could easily fit in there but Image module is much widely used than web vitals so I thought that I would add these hints here. Also, regarding nuxt-performance separate moduel. From such module, I would expect thst it could do certain perf improvements automatically for me (which wont be the case because majority of these hints are a recommendations, not written in stone rules). So having a module that would just display hints in the browser didnt make sense for me. Regarding a new component for LCPImage. This could work, but some of these hints should be verified by the real user before applying. I might try to create a proof of concept component that would do that but at this point the most useful for me would be these hints that would let me know what I should to have a better result in LCP
|
✅ Live Preview ready!
|
It could also be useful to show the LCP diagnostic metrics: TTFB, resource load delay, resource load time, and element render delay. |
Thanks @rviscomi ! I think for these more advanced diagnostic metrics we could implement them as next features if this functionality will be useful :) |
Any other feedback @manniL @harlan-zw @pi0 ? 🙂 |
Can I do snything about this PR to be merged? :) |
fef3a50
to
afe4120
Compare
@Baroshem why did you close this PR? 👀 |
It was there for about 6 months without any update from the package maintainers. Also, we recently decided to create a package called nuxt hints that would show this and othe rkind of hints to the user so that he can easily make his app better |
I see, thank you for the explanation! |
@Baroshem, where can I find more information about this package? |
Hey @riddla This is still in progress and to be honest, I cannot give you any estimation :( |
Closes #762
Largest Contentful Paint hints in development
This PR adds a new client only plugin that will be registered only in development mode. The main purpose of this functionality is to warn users using Image module in the browser console about popular performance issues with images such as:
loading="lazy"
attributewebp
fetchPriority="high"
width
andheight
attributes set (bad for both LCP and CLS)How it works?
The plugin is using Performance Observer API under the hood to find the potential LCP element and measure metric values such as load time.
Later on, a set of statements is checking whether this LCP element matches the good practices and follows the Optimize LCP document values and recommendations. If not, warnings are displayed in the browser that would allow users to faster find performance bottlenecks and issues. Screenshot below for reference:
Todo
Next steps
Keep in mind that this PR is just beginning of the hints that we can show to the users that would allow them to have a better performing website (and improve Lighthouse and Core Web Vitals score).
I have been thinking about developing a functionality that would fix these kind of issues automatically (something like fontaine plugin) but I failed because there is no way to detect LCP programatically (without access to browser) but maybe someone else here would have some interesting ideas for that.
Feedback
As always, I am opne for suggestions on what can be improved here. Let me know what can be done better or different way so that we can help users develop more performant websites :)