nuxt icon indicating copy to clipboard operation
nuxt copied to clipboard

User timings for @nuxt modules

Open Spunkie opened this issue 5 years ago • 3 comments

Is your feature request related to a problem? Please describe.

Originally bought up in https://github.com/nuxt-community/i18n-module/issues/815 and related to https://github.com/nuxt/nuxt.js/issues/6467

It's not always obvious what makes up script evaluation times in a live deployment, or how much an initial performance impact comes from adding new modules. This is especially an issue if you are looking at your site through a non-interactive report generated by a perf tool like lighthouse or sitespeed.io.

Describe the solution you'd like

It would be nice if the user timings api could be used to automatically add performance marks to all nuxt modules. That way it's super obvious the performance impact of each module.

Describe alternatives you've considered

Even if it's not technically possible to add marks automatically at the nuxt level because of all the different possibilities. It could at least be made standard practice in @nuxt and nuxt-community managed modules to add some level of user timing marks.

Additional context

https://web.dev/user-timings/ https://developer.mozilla.org/en-US/docs/Web/API/User_Timing_API/Using_the_User_Timing_API

Spunkie avatar Aug 02 '20 06:08 Spunkie

I guess you've made a mental shortcut but "modules" run at build time so it wouldn't be that important to time that.

What Nuxt can and should time is:

  • plugins
  • middleware
  • initialization of internal plugins like VueRouter and other
  • ...

For plugins and middleware it would probably need to track from which modules those came (if they did) so that one could tell by looking at the metrics.

rchl avatar Aug 03 '20 07:08 rchl

Assigning myself to remember, this is indeed a feature and we will look at this when we will work on the Nuxt Metrics.

Thank you for this issue @Spunkie

atinux avatar Dec 03 '20 12:12 atinux

@Spunkie There is an in progress module to do some of this, though I wouldn't recommend using it outside of development or local testing: https://github.com/danielroe/nuxt-timings-module

Feedback and feature requests are welcome 😊

danielroe avatar May 22 '21 15:05 danielroe

We are approaching the Nuxt 2 EOL date (June 30, 2024) - see this article for more information. I'm closing this issue as it's marked as a Nuxt 2 related enhancement and it's not a critical issue.

That doesn't mean it might not be relevant for Nuxt 3. If it is, please feel free to open a new issue (or just comment, and I can reopen it). 🙏

Thank you for your understanding and for your contribution to Nuxt! 🎉

danielroe avatar Jun 14 '24 16:06 danielroe