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 size #5862

Open
5 tasks
gnestor opened this issue Jan 14, 2019 · 8 comments
Open
5 tasks

Reduce bundle size #5862

gnestor opened this issue Jan 14, 2019 · 8 comments

Comments

@gnestor
Copy link
Contributor

gnestor commented Jan 14, 2019

Follow up from #5722 (comment)

  • xterm could be lazy loaded
  • santitize-html too big
    • What's it doing with postcss?
  • moment is too big
    • Import submodule
  • vim keymap for codemirror
    • Lazy load keymaps
  • do we need esprima? Can we lazy-load it?
  • ajv could be lazy-loaded

cc @ian-r-rose

@gnestor
Copy link
Contributor Author

gnestor commented Feb 13, 2019

How to lazy load large libraries in lab extensions: jupyterlab/jupyterlab-latex#107

@bollwyvl
Copy link
Contributor

An example up for xterm on #5994. Not great, but does save ~350kb

Sanitizer is hard, as its API would have to change, as it is currently synchronous.

I didn't realize how brutal the blueprint stuff really is: because it's used by every toolbar, there's no point in moving it out of the vendors-main monolith.
path884

Pretty late in the game at this point, but I feel like we either need to ramp up our usage to use every single bell and whistle in there... or forbid use of it in the critical path (any sidebar, menu, launcher, etc.), and figure out a way for them to get them conveniently lazy loaded.

@ian-r-rose
Copy link
Member

Yeah, sanitizer it tough. A shame postcss is so large.

ajv may be doable. The settings API is mostly async, with just one synchronous function that would need to be a breaking change.

@bollwyvl
Copy link
Contributor

The settings API is mostly async, with just one synchronous function that would need to be a breaking change.

Is it even worth it if it has to be loaded every time? Does settings loading block any UI drawing? If so, there's no real benefit, as it's an extra connection. The only place we can really win for "clean" first start is things that won't be used at all until you decide what you are going to do: codemirror actually would be a candidate, and we as sure as shooting would want to not be loading monaco in the hot path.

@bollwyvl
Copy link
Contributor

I had a look at moment: we're only using two functions from moment (formatting and relative time). We already have date-fns in the lockfile, so i took a look at that. Because of how we vendor, it won't tree-shake out, but it's still a good deal smaller... will try to PR if I get a chance...

@ghost
Copy link

ghost commented Feb 18, 2019

Can't personally vouch for it but have read about Day.Js as an alternative, formatting and relative time just cost 2kb+

⏰ Day.js 2KB immutable date library alternative to Moment.js with the same modern API

https://github.com/iamkun/dayjs

reference: moment/moment#2373 (comment)

@vidartf
Copy link
Member

vidartf commented Feb 18, 2019

Somebody mentioned previously that moment.js could be optimized by using submodule imports. Is this the case?

@bollwyvl
Copy link
Contributor

bollwyvl commented Feb 18, 2019 via email

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

No branches or pull requests

5 participants