Luxon: Better Documentation regarding Size and Tree-Shaking

Created on 13 Jan 2021  路  2Comments  路  Source: moment/luxon

Hello!

This follows from from https://github.com/moment/luxon/issues/703 and https://github.com/moment/luxon/issues/94#issuecomment-346481639.

So, I have just moved from moment to luxon for the reasons listed on the moment homepage. When I read about using native APIs in more modern libraries or new versions of old libraries, I guess I assume that the new library will have a size savings, as well. Imagine my surprise, then, when I finally migrate everything over and find out that my vendor.js production-built file size has _increased_ by 170kB minified and 53kB gzipped!! (Update: the comparison I did was not apples to apples; the more accurate increase is 18kB and 4kB, respectively.)

Had I known this ahead of time, I probably would've stuck with moment or moved to another library like Day.js (I still might). I'm currently not using moment's locales or its timezone addition, and at another company, I provided my own short-list of timezone data to keep moment's size down. In a similar manner, I'm not using the bulk of what Luxon exports (ie Interval and Zone), but since it's not modular I can't tell webpack, for example, to leave certain modules out.

I've read discussions on things people have tried in attempt to make their file sizes smaller, but what I'd really like is a consensus on what to do for each of the popular build tools/environments, and have that be listed in the Luxon documentation page. For example, how can I point my build to use the smaller global-es6/luxon.min.js instead of cjs-browser/luxon.min.js that it's currently using?

Additionally, I think it'd be really helpful to be upfront about the size costs of using Luxon (especially that you are comparing it with the fully-loaded moment library). One ideal place would be in the moment homepage under the Reasons to keep using Moment section that discusses Luxon鈥攌nowing that library size does not actually get smaller but rather increases would be really helpful to know when comparing alternatives.

Thank you for reading!!

All 2 comments

170kb is big in 2021? How about utilizing the browser cache with versioning? I guess it is negligible.

170Kb would be a lot... but 24 Kb is ok.

@tcsaddul While 170Kb doesnt sound like a lot, it actually matter once things start to add up. If every libary u use would increase its size by 170Kb, you would increase the loadings times by a lot... even in 2021. In worst case, you can loose a lot of users, just because of increased loading times. It depends on the project ofc, but overall its not something that you shoulnd't care about, if you're creating a website on a professional level.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jasonwilliams picture jasonwilliams  路  6Comments

peterjanes picture peterjanes  路  5Comments

icambron picture icambron  路  5Comments

dnalborczyk picture dnalborczyk  路  3Comments

pmcilreavy picture pmcilreavy  路  6Comments