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?

1 Answer

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.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like