Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vue js is it ok to register all components globally?

Is it ok/good practice to register all components globally?

Reason

  • to avoid doing of imports of components manually when other components needed them.
  • a bit annoyed seeing component with lots of import when the app gets bigger.

Are there any downside of this?

like image 247
PenAndPapers Avatar asked May 29 '19 03:05

PenAndPapers


1 Answers

You generally shouldn't register a component globally if you aren't going to use it frequently throughout your application. Quoting the docs ...

Global registration often isn’t ideal. For example, if you’re using a build system like Webpack, globally registering all components means that even if you stop using a component, it could still be included in your final build. This unnecessarily increases the amount of JavaScript your users have to download.

like image 56
Husam Ibrahim Avatar answered Nov 09 '22 16:11

Husam Ibrahim