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

Optimize: Reduce Bundle Size Further #55

Open
4 tasks done
mithi opened this issue Jun 16, 2020 · 5 comments · May be fixed by #106
Open
4 tasks done

Optimize: Reduce Bundle Size Further #55

mithi opened this issue Jun 16, 2020 · 5 comments · May be fixed by #106
Labels
help wanted Extra attention is needed optimization Improving performance, efficiency of the app up for grabs

Comments

@mithi
Copy link
Owner

mithi commented Jun 16, 2020

Using only a partial bundle of Plotly reduced the bundle size by 50%.
Right now, Plotly still occupies 75% of the bundle.
#54

Other things that we can try:

  • Remove MathJS as dependency and just write all the matrix multiplications from scratch
  • Remove ReactMarkdown and just write them in html
  • Figure out if react-icons is taking up more space than it should
  • Check if it's a good idea to use preact and eject

Related Links

Eject

Preact

Codesplitting

Importing only one icon from react-icon

@mithi mithi added help wanted Extra attention is needed optimization Improving performance, efficiency of the app good first issue Good for newcomers and removed good first issue Good for newcomers labels Jun 16, 2020
@mithi
Copy link
Owner Author

mithi commented Jun 22, 2020

Bundle-size reduced by about 10 percent when mathjs was removed

See #77

@mithi
Copy link
Owner Author

mithi commented Jun 25, 2020

Started with

84758276-d3000c00-aff7-11ea-8b5e-ddf4540929f2

84758285-d72c2980-aff7-11ea-9181-d84dc7d1fab8

After using partial plotly bundle

85318791-2b9d4080-b4f3-11ea-862a-6b21a6108429

After removing mathjs

85318826-3952c600-b4f3-11ea-9dd5-960619d5d6c5

85318883-538ca400-b4f3-11ea-9afa-63b2fbbcf2de

@icyJoseph
Copy link
Contributor

I have a branch where React Markdown has been removed and the Pages are split into a bundle of its own.

image

Which ends up at roughly 1.76 MB, as follows, with 7.3ea032e0.chunk.js being Plotly D3, which is dynamically loaded, so it doesn't block first paint. The other main bundle 6.3db6acf1.chunk.js is the react-plotly.js/factory module, also dynamically loaded.

4096	build/precache-manifest.9260a653dee23e8e967e8f2a9c3bc098.js
4096	build/static/js/Landing.da6e3571.chunk.js
4096	build/static/js/FwdKinematics.f7b1e2d0.chunk.js
4096	build/static/js/runtime-main.7c59d658.js
4096	build/static/js/InvKinematics.1f0dbfd6.chunk.js
1474560	build/static/js/7.3ea032e0.chunk.js
188416	build/static/js/6.3db6acf1.chunk.js
4096	build/static/js/LegPattern.65248188.chunk.js
49152	build/static/js/main.0d6601bf.chunk.js
8192	build/static/js/8.e4f8fe4a.chunk.js
8192	build/static/css/main.1739d554.chunk.css
4096	build/service-worker.js
4096	build/index.html
1761280	total

Compared to running on master as of now, which ends up at 1.79MB, big win yay!

4096	build/precache-manifest.2b3e83a9c10cab01a0fa7334d2b6b0bf.js
1724416	build/static/js/2.2d4e33b3.chunk.js
4096	build/static/js/runtime-main.d4e56be3.js
49152	build/static/js/main.384eb958.chunk.js
8192	build/static/css/main.25fbfe7e.chunk.css
4096	build/service-worker.js
4096	build/index.html
1798144	total

The biggest win is that you can paint the first screen faster. Next step, though not blocked by this, would be to enable the service worker and have a sound offline mode.

I still need to do some work on the PR, but might come up soon.

@mithi
Copy link
Owner Author

mithi commented Jul 4, 2020

@icyJoseph , thanks! Because I've merged your PR multiple times, I'll like to add you at the bottom of this repo's README as one of the main contributors. I'd do this if that's alright with you :)

@icyJoseph
Copy link
Contributor

Oh thank you! Like I said before I really like this project! So yeah, that's alright!

@icyJoseph icyJoseph linked a pull request Jul 7, 2020 that will close this issue
@mithi mithi linked a pull request Jul 8, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed optimization Improving performance, efficiency of the app up for grabs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants