Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce bundle.js size #1268 #2667

Merged
merged 5 commits into from Feb 21, 2022
Merged

Conversation

IhsenBouallegue
Copy link
Collaborator

@IhsenBouallegue IhsenBouallegue commented Feb 16, 2022

Reduce bundle.js size

Close: #1268

Description

Descriptive pull request text, answering:

  • Add webpack plugins to reduce the size of JS files

grafik

Size of bundle.js and bundle.js.map:
Before minimizing js:
grafik
After minimizing js:
grafik

Size of bundle.js:
Before minimizing js:
grafik
After minimizing js:
grafik

@IhsenBouallegue
Copy link
Collaborator Author

Minifying the bundle breaks the app.
It seems that it has to do with AngularJS:
https://stackoverflow.com/questions/62677457/webpack-minimize-option-breaks-application-if-set-to-true
We need to look further into that.

@BridgeAR
Copy link
Member

@IhsenBouallegue good catch! We could deactivate renaming the variables as a first step and later on implement the suggestion from stackoverflow.

@IhsenBouallegue
Copy link
Collaborator Author

IhsenBouallegue commented Feb 18, 2022

@IhsenBouallegue good catch! We could deactivate renaming the variables as a first step and later on implement the suggestion from stackoverflow.

I agree!
And for the sake of documentation, here is a summery:

  • I tried solving it with ng-annotate-webpack-plugin (which is deprecated) and it didn't work.
  • I tried solving it with babel-plugin-angularjs-annotate (which we already have installed) and it didn't work.
  • Finally, I resorted to disablign keep_classnames and keep_fnames. Which worked and surprisingly had an acceptable impact on the size (about 2.9 MB increase)
    So the numbers look pretty much the same and now it should work.
  • It is also worth mentioning that I tried minifying the HTML and CSS, but that resulted in undefined variables and many errors. So I left it out.

From what I tested on version 1.90.0, we have a 60% decrease in size of bundle.js and about 20% decrease in overall build size. Which is well worth it 💯

@IhsenBouallegue IhsenBouallegue marked this pull request as ready for review February 18, 2022 13:20
@sonarcloud
Copy link

sonarcloud bot commented Feb 18, 2022

[CodeCharta Analysis] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@sonarcloud
Copy link

sonarcloud bot commented Feb 18, 2022

[CodeCharta Visualization] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link
Collaborator

@ce-bo ce-bo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice improvement! 🚀
On my machine, the median loading time of bundle.js is roughly at 185ms (before the median was 400ms).
The transmitted bytes (over network) for bundle.js is now 1.3MB (before it was 2.9MB) which is an improvement of 123%!

@IhsenBouallegue IhsenBouallegue merged commit 1745198 into main Feb 21, 2022
@IhsenBouallegue IhsenBouallegue deleted the fix/1268/reduce-bundlejs-size branch February 21, 2022 08:07
@IhsenBouallegue IhsenBouallegue restored the fix/1268/reduce-bundlejs-size branch February 21, 2022 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reduce bundle.js size
3 participants