Skip to content
This repository has been archived by the owner on Jul 6, 2020. It is now read-only.

[Enhancement] Lazy load components #274

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

jayaike
Copy link
Contributor

@jayaike jayaike commented Jan 15, 2020

Issue: #257

I have lazy-loaded all the routing modules. Below are the stats.

Development

Initial EvalAI-ngx Bundle size - 1.26MB (1290.24KB)

Current Bundle Size after optimization - 352KB (0.34MB)

Optimization ------- 72.7%

Production

Initial EvalAI-ngx Bundle size - 1.61MB (1648.64KB)

Current Bundle Size after optimization - 945KB (0.92MB)

Optimization ------- 42.8%

Methodology

Step 1: Feature Modules

I broke up all the components into feature modules in order to import them lazily. I divided them by purpose and route.

Step 2: Import Lazily (Change Routes)

I had to change all the routes to lazily import the feature modules. This way the user only loads the modules he/she uses at the time of need.

Step 3: Change Method of lazy-loading to PreloadAllModules

Basically, what PreloadAllModules does is it waits for the initial component to load then it starts loading other links so as to reduce the loading time when navigating to other routes.

As shown above, this new way of loading modules in EvalAI-ngx will increase the loading time of EvalAI-ngx and also improve User Experience by making the webpage smoother because it does not have all the modules loaded at once.

Although it took a whole night 🤣😂....It was worth it!

@Ram81 @RishabhJain2018 @pushkalkatara @Sanji515 @lunayach @vkartik97 Please let me know your thoughts.

@codecov-io
Copy link

codecov-io commented Jan 15, 2020

Codecov Report

Merging #274 into master will decrease coverage by 0.01%.
The diff coverage is 33.33%.

@@            Coverage Diff             @@
##           master     #274      +/-   ##
==========================================
- Coverage   50.66%   50.64%   -0.02%     
==========================================
  Files          66       66              
  Lines        3766     3771       +5     
  Branches      442      444       +2     
==========================================
+ Hits         1908     1910       +2     
- Misses       1763     1766       +3     
  Partials       95       95
Impacted Files Coverage Δ
...e/challengesettings/challengesettings.component.ts 45.16% <33.33%> (-0.46%) ⬇️
Impacted Files Coverage Δ
...e/challengesettings/challengesettings.component.ts 45.16% <33.33%> (-0.46%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 607a297...c0e0742. Read the comment docs.

@jayaike jayaike mentioned this pull request Jan 15, 2020
@Sanji515
Copy link
Member

Screenshot from 2020-01-16 02-18-32

@nsjcorps I'm getting this error, can you please take a look at this?

@jayaike
Copy link
Contributor Author

jayaike commented Jan 15, 2020

I guess this should be the key angular/angular-cli#14566

@jayaike
Copy link
Contributor Author

jayaike commented Jan 15, 2020

It's as a result of the lazy modules. The syntax is correct though. @Sanji515

@jayaike
Copy link
Contributor Author

jayaike commented Jan 15, 2020

Do you use yarn or npm. I use yarn

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants