popcode icon indicating copy to clipboard operation
popcode copied to clipboard

Replace Moment.js with a lighter-weight alternative

Open outoftime opened this issue 7 years ago • 2 comments

Moment.js contributes a disproportionately large proportion of our bundle size given its limited actual use in the application. dayjs is an API-compatible replacement that is much smaller, though we would have to confirm it supports the browsers/versions we need. date-fns is another library that, while not API-compatible, has been much-touted recently as a good replacement for Moment.

To evaluate effectiveness at reducing bundle size, you can build a production-like environment with:

$ PROFILE_BUILD=true npm run preview

And then access:

  • http://localhost:3000/profile/bundle-analyzer.html
  • http://localhost:3000/profile/webpack-visualizer.html

outoftime avatar Apr 29 '18 09:04 outoftime

Happy to take this on!

omardeleo avatar Oct 24 '18 00:10 omardeleo

Currently we're using Chrono which itself depends on momentjs. However they plan to switch to dayjs. Once that is done, Popcode can upgrade chrono, switch to dayjs and reap the benefits.

See https://github.com/wanasit/chrono/issues/285

I have a local Chrono branch where I've started the porting process. We'll see whether I finish my branch or they update it themselves first.

razzius avatar Sep 06 '19 19:09 razzius