Skip to content

Using ESM adds considerable load time #3007

Answered by josdejong
brenc asked this question in Q&A
Discussion options

You must be logged in to vote

Just using mathjs for the round function looks like overkill, if a more lightweight library like lodash works better just use that :).

I've indeed also noticed that ESM is much slower than CJS. We cannot do anything about that in this library though.

mathjs is quite a large library, and by default it loads the whole library, which is much if you only use a single function. The ESM and CJS contains hundreds of files, since every function is written in a separate file. Loading separate files is relatively slow, and for example loading the UMD bundle of mathjs is much faster. We are making plans to make mathjs more modular, but that will take time.

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by brenc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants