Live data from Hacker News

Day.js – Fast 2kB alternative to Moment.js with the same modern API

day.js.org

101–110 of 141 posts

Re: Day.js – Fast 2kB alternative to Moment.js with the same modern API

#101

Interesting to see the support for luxon. When moment was announced as a done project they recommend a number of alternatives; one of those was luxon. Date-fns was also in there, and given I was already using it I carried on my merry way! I'm curious what the difference between luxon and date-fns is. Npm trends are interesting https://npmtrends.com/date-fns-vs-dayjs-vs-luxon-vs-moment

IIRC, moment's website listed luxon as their recommended replacement via a top-site banner. The banner seems gone now, but luxon is still the first listed on the recommendations page.

Re: Day.js – Fast 2kB alternative to Moment.js with the same modern API

#102
post #26

What is the obsession with xKB? With tracking, analytics, monitoring and gazillion other scripts, I'd wager that an average webpage size is probably closer to 1MB. Checked some of the popular sites (caching enabled)- Amazon.com - 4.8MB Google.com - 2.5MB

Not everyone has high speed internet. :(

Re: Day.js – Fast 2kB alternative to Moment.js with the same modern API

#103

Earlier quoted context omitted.

Smaller bundle size, similarity to moment.js As a dev who’s used all three, is there a massive difference? Not really. Stick with what you like (though moment is no longer maintained so maybe not that)

Moment is still being maintained, but will not receive any new features.

Moment’s own docs tell you to not use moment

Re: Day.js – Fast 2kB alternative to Moment.js with the same modern API

#104

If you are considering switching to a (different) date library, I would suggest to hold off. ECMAScript is about to introduce a native date and time API that is much better than the current Date functionality. It may also make the need for a third-party date library obsolete (as long as you do not need to parse custom date formats). - https://github.com/tc39/proposal-temporal - https://github.com/tc39/proposal-tempor…

> I would suggest to hold off

you don't need to hold off - you just wrap the library in an api of your own, specific for your usage. Then, when/if the ecmascript standard library adds a good one in, you just need to re-implement the wrapper, which would be presumably pretty easy as the api surface area is fairly small.

Re: Day.js – Fast 2kB alternative to Moment.js with the same modern API

#107
post #104

If you are considering switching to a (different) date library, I would suggest to hold off. ECMAScript is about to introduce a native date and time API that is much better than the current Date functionality. It may also make the need for a third-party date library obsolete (as long as you do not need to parse custom date formats). - https://github.com/tc39/proposal-temporal - https://github.com/tc39/proposal-tempor…

> I would suggest to hold off you don't need to hold off - you just wrap the library in an api of your own, specific for your usage. Then, when/if the ecmascript standard library adds a good one in, you just need to re-implement the wrapper, which would be presumably pretty easy as the api surface area is fairly small.

Date libraries and small API surface areas are not usually things I associate with each other.

Re: Day.js – Fast 2kB alternative to Moment.js with the same modern API

#108
Moment.js gets a lot smaller if you apply the same trick Day.js is using here, that is, to just load the locales that you need.

See https://medium.com/rise-engineering/how-we-managed-to-shed-3... for an example. Takes Moment.js from 364KB to 59KB. Still much larger than 2KB, but perhaps small enough.

Re: Day.js – Fast 2kB alternative to Moment.js with the same modern API

#110
post #108

Moment.js gets a lot smaller if you apply the same trick Day.js is using here, that is, to just load the locales that you need. See https://medium.com/rise-engineering/how-we-managed-to-shed-3... for an example. Takes Moment.js from 364KB to 59KB. Still much larger than 2KB, but perhaps small enough.

Moment has always been absurdly large. There's really no reason for it. The vast majority of usages can be solved with 4 lines of native `Date` object based code.
Post reply on HN