6 ms·
How does this compare in file size to Moment? That's the only real issue I have with it.
by ianstormtaylor 9y ago
How does this compare in file size to Moment? That's the only real issue I have with it.
- pygy_ 9y agoAfter minification with Uglify: 27.3 KB compressed with `gzip -9`, 26.4KB with `zopfli -i1000` and 24.0KB with `brotli -q 11`. (kilo, not kibi)
- collectively 9y agoTIL they just completely redefined a kilobyte a while ago.
- orf 9y agoCan you elaborate?
- collectively 9y agoAt some point, a kilobyte was 1024 bytes. Now, a kilobyte is 1000 bytes, and 1024 bytes is a kibibyte. I mean, it does make sense. But it just sounds off to me.
- seanp2k2 9y agoHard drive manufacturers have been doing this for decades. This is why the “80GB” drives were 74.5GB in Windows. It’s more complicated with SSDs: https://www.anandtech.com/show/2829/7 https://www.anandtech.com/show/2829/7 EDIT: the official “kibibyte” was standardized in 1998: https://physics.nist.gov/cuu/Units/binary.html https://physics.nist.gov/cuu/Units/binary.html so almost 20 years ago. Blame Windows and HDD mfgs for sticking with the SI definitions.
- sd8dgf8ds8g8dsg 9y agoYea, bad bad windows for following standards. The SI prefixes are well established before 1998 and the cause for this brainmelt. https://en.wikipedia.org/wiki/Metric_prefix https://en.wikipedia.org/wiki/Metric_prefix
- collectively 9y agoWell to be fair “GB” could refer to either prefix.
- CodesInChaos 9y agoWindows (at least up to 8) does not follow the SI standard. It uses KB, MB, GB but converts using 1024. Which has funny consequences, like 999MB being smaller 0.94GB.
- icambron 9y agoI'd love to make it smaller. Several of the builds contain polyfills for newish JS features not supported in IE. I'd like to strip that out and shave off a few k.
- hjnilsson 9y agoSo actually larger than moment (which is 16.3kb gzip)? Hopefully it will improve over time. API looks better than moment though.
- dawkins 9y agoIf you only want timezone conversions I removed everything else from Moment. It's less than 2KB uncompressed: https://github.com/scorredoira/timezone.js https://github.com/scorredoira/timezone.js
- pitaj 9y agoI my experience the actual timezone information is the heaviest portion of the payload. I can't wait until all browsers have support for `Intl`
- seanp2k2 9y agoThat any computers talk to each other about time in any other terms than epoch is insane to me. From there, converting it to local time zone is pretty easy, but it should be a presentation-layer ONLY thing. If you’ve ever worked with or implemented a system where this wouldn’t work, I’m interested in hearing about why.
- pitaj 9y agoAh, sorry. I was speaking more in terms of internationalization than actually converting between time zones. All you need is a database, but that database can be hard to maintain and can be very large.
- gjjrfcbugxbhf 9y agoWhy epoch over UTC?
- CodesInChaos 9y agoIf you schedule a meeting in the future you typically agree on a local time in a specific timezone. So the (local time, timezone) tuple is the authoritative value you want to store (you can cache the utc time if you want). Just storing the utc time and timezone is problematic, since the conversion function between utc and local can change via tz database updates, sometimes with little notice (Israel is notorious for sometimes only deciding on the DST switching date shortly before it happens). In principle you could store (utc-time, offset used to convert from local, timezone), but I find that rather unintuitive and error prone, since it doesn't cleanly separate authoritative from cached values.