Kekule.js icon indicating copy to clipboard operation
Kekule.js copied to clipboard

dynamic module loading improves module import size?

Open filoscoder opened this issue 2 years ago • 4 comments

We are importing Kekule like below Screenshot 2022-11-12 at 9 34 40 PM

The size is huge, we only need IO, Editor, and ChemWidget modules. There is any way of importing modules with improved bundle sizes?

Can you provide examples of dynamic module loading please?

filoscoder avatar Nov 12 '22 13:11 filoscoder

Hi @filoscoder, if only certain modules are needed, you can use the utils/jsMinifier/ to build a custom min js file including only those modules to reduce the file size. E.g.:

node utils/jsMinifier/run.js -m io,chemWidget -d my/dest/path

Then use the custom kekule.min.js (not kekule.js):

import { Kekule } from "path/kekule.min.js";

However, since the editor is the most complex widget in package and requires a lot of functions from other modules, the reduced size is quite limited in the method above (from 2.56MB to 2.15MB).

partridgejiang avatar Nov 15 '22 03:11 partridgejiang

Hi @filoscoder, if only certain modules are needed, you can use the utils/jsMinifier/ to build a custom min js file including only those modules to reduce the file size. E.g.:

node utils/jsMinifier/run.js -m io,chemWidget -d my/dest/path

Then use the custom kekule.min.js (not kekule.js):

import { Kekule } from "path/kekule.min.js";

However, since the editor is the most complex widget in package and requires a lot of functions from other modules, the reduced size is quite limited in the method above (from 2.56MB to 2.15MB).

I'm not following where is utils/jsMinifier, is a helper inside Kekule? Anyways It seems pretty unnecessary to customize the build for such a tiny difference. Thanks a lot for testing it beforehand!

filoscoder avatar Nov 15 '22 06:11 filoscoder

The jsMinifier util is in the source code repo: https://github.com/partridgejiang/Kekule.js/tree/master/utils/jsMinifier , :).

partridgejiang avatar Nov 15 '22 13:11 partridgejiang

The jsMinifier util is in the source code repo: https://github.com/partridgejiang/Kekule.js/tree/master/utils/jsMinifier , :).

niceee, thanks a lot 🤙🏼

filoscoder avatar Nov 16 '22 01:11 filoscoder