Home > Blockchain >  Is using nuxt.js components auto import bad for performance?
Is using nuxt.js components auto import bad for performance?

Time:04-09

I'm using Nuxt.js v2 for my project. Right now, I've enabled nuxt.js auto import for components by setting components: true in my nuxt.config.js file. I'm wondering if using components auto import has any negative effect on performance of my site in production?
Should I import components manually like what you do in vue.js?

CodePudding user response:

The auto-import feature is just for some DX (developer experience) to not have to type the whole thing. The template will be scanned when you're shipping your code (or during compilation maybe) but the performance will be exactly the same as if you're importing the component manually.

At the end, the parsing needs to be done by the Vue render engine anyway. So, here the Nuxt team is providing a tool that helps you code faster, it's not doing more compilation on the template itself but ahead of time.

Hence why no performance penalty.


There is actually quite a lot of libraries (Nuxt3, Vitesse, etc...) with the auto import of components and Composition API hooks done for you. Don't worry since if it had any impact, it would not be used that widely.

  • Related