Skip to content

Optimize javascript bundle #577

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

Merged
merged 3 commits into from
Oct 8, 2020
Merged

Conversation

colby-swandale
Copy link
Member

@colby-swandale colby-swandale commented Oct 8, 2020

Context

The current application javascript bundle size is really large (several MBs big) and takes forever for a browser to fully process. This is causing issues with the theme switcher setting the light/dark theme well after the DOM has started rendering and causing a flickering effect. See #573

This issue is caused by 2 main issues:

  1. when I added the new repl page page, I packaged the entire Monaco editor in the JS application (which is several MBs big).

  2. The Monaco editor is packaged in the same javascript bundle that is served for the docs pages.

Fixes

This PR solves both issues by:

  • Configuring the Monaco editor WebPack plugin to only include the bare essentials that's needed for the Repl page.
  • Create a separate javascript bundle so that Monaco-editor is only ever loaded when the user visits the Repl page.

File Before/After

Before
Application JS: 3.3MB

** After: **
Application JS: 70KB
Repl JS: 2.2Mb

@colby-swandale colby-swandale changed the title Optimise javascript bundle Optimize javascript bundle Oct 8, 2020
@natematykiewicz
Copy link
Contributor

Once you mentioned that the REPL change made it big, I was thinking extracting the REPL out of application.js would make a ton of sense. This PR looks great to me.

@colby-swandale colby-swandale merged commit f5284c7 into master Oct 8, 2020
@colby-swandale colby-swandale deleted the colby/optimise-javascript-bundle branch October 8, 2020 22:28
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.

2 participants