Sushil Sharma
Sushil Sharma

Reputation: 21

Does separating the modules in Angular makes it faster?

In Angular we have only app.module.ts when we generate the App from CLI.

But we can either separate it or can keep all components in one app. module.ts like.

So my question is does separating it makes application load faster?

Upvotes: 0

Views: 1185

Answers (3)

Siddharth Jaiswal
Siddharth Jaiswal

Reputation: 46

No sir, we should not make different modules for every component as it can make our app heavyweight.

For your information, we can split modules on their characteristics like auth module for authentication (sign-in/sign-up), Profile for (profile detail/create/edit/remove) etc..

Each module should be with a minimum of 5 components (just best practice not bounded with it ) and also the size of a module should not be more than 2MB.

These are just practices so don't stick to it, parameter defer as project specification.

Upvotes: 1

Surjeet Bhadauriya
Surjeet Bhadauriya

Reputation: 7156

No, Creating separate modules does not make your application load faster.

But using LAZY LOADING with separate modules makes your application load faster.

Separating the modules is a concept of making things neater and cleaner structure wise. But if you use LAZY LOADING to load those separate modules, then it will load your modules when it is needed in the app. So it increases the app performance.

You can get more info on Separation of module here:

Import and Export Core Module and Shared Module

Upvotes: 0

Mridul
Mridul

Reputation: 1366

We don't make different 'app.module.ts' for each component in angular. app.module is the root file for your application which helps you in application need such as a user workflow, routing, or forms. using specific module.ts for your components just adds functionality to that particular component.

Upvotes: 0

Related Questions