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

Lighten the bundle size #170

Open
paultranvan opened this issue Sep 21, 2021 · 2 comments
Open

Lighten the bundle size #170

paultranvan opened this issue Sep 21, 2021 · 2 comments

Comments

@paultranvan
Copy link
Contributor

paultranvan commented Sep 21, 2021

According to this analyzer, cozy-keys-lib's bundle takes 426 Ko.
We could gain some space by removing heavy and dispensable libs, typically node-forge or tld.js.
Previous work like #43 already improved the weight, although not everything went as planned: #73

tldjs is used to get the domain which can be easily reimplemented in a stub see its definition

node-forge (which can actually be used in browser, despite the name) is used for two things:

  1. support for old browsers that does not have subtle crypto API, such as IE or old Safari
  2. "fast" crypto operations, brought by this commit. It is unclear how it is fast compared to the subtle API and how useful it actually is

The 1. does not seem to be a problem, as we officially does not support IE, and only support Safari >=12, which support subtle API. About 2., this require to keep most of the existing node-forge imports, but newer jslib's versions seem to remove this need.

@Crash--
Copy link
Contributor

Crash-- commented Sep 22, 2021

Stubbing getDomain from tldjs is not as easy as it can seems.

When the JSLib request getDomain it gets this one https://github.com/oncletom/tld.js/blob/b758887c0d01a12b6c0f048a544377e8d44368db/index.js#L114 . And this one call parse and parse need to have the rules.json file.

@Ldoppea
Copy link
Member

Ldoppea commented Sep 22, 2021

Do you have an idea of how much weight we can save?

but newer jslib's versions seem to remove this need.

The methods you linked have not been edited for 4 years 🤔

cozy-keys-browser is using a recent jslib version from july 2021.
cozy-pass-web is using one from may 2021.
Maybe it would be a good idea to update cozy-keys-lib's one. Also I may need to do it soon if I expect to mutualise recent changes from cozy-keys-browser and cozy-pass-web.

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

No branches or pull requests

3 participants