Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Consider using the Closure Library for CLJS #33
js-joda is quite a gigantic library and just by including it you are adding almost 500KB of JS to your build. The Closure Library itself actually contains a whole bunch of utilities for working Data/Time data and unlike js-joda it is fully DCE compatible. You can find the code in the goog.i18n.* namespaces
I uploaded a sample build report generated by shadow-cljs to show how huge the added code is. Something also includes
Apologies if this was considered before and rejected but code size is important for Browser builds and this is entirely too big (IMHO).
Thanks for the report, there are a few points I can make on this:
Firstly the 500k is js-joda and two addon packages. js-joda alone is 200k - and that will likely suffice for some users. More info here: http://juxt.pro/tick/docs/index.html#_timezones
WRT 'too big', too big for whom? I guess you're saying any site where load time is important and/or bandwidth is limited. I'm not developing such size-critical pages myself but I would be surprised if people were using clojurescript on landing pages etc because that itself is at least 200k. I guess you have a certain size budget in mind for each kind of page you're developing and for some people this will blow the budget and won't fit their needs. I'm aware of date-fns for the 'I need more than the platform date lib, but can't afford much more' thing, ie https://github.com/you-dont-need/You-Dont-Need-Momentjs
but let's assume cljs is in budget but an extra 200k isn't. Firstly it looks like js-joda is amenable to shaking, see js-joda/js-joda#214. not sure how you'd do that from cljs ... build with webpack possibly I'm not sure.
In my talk at Clojure/North I talk about new platform dates: https://github.com/tc39/proposal-temporal and size was partly what I had in mind there. I'll have more of a look at goog.i18n but I don't think I'll be trying to get it onto that as js-joda is within budget for the things I'm building and I value being able to drop to java.time api from tick if I need to.
Actually as far as the addon libs go, I think those could be made smaller. e.g. the timezone addon adds zone info for all zone going back way into the past, but maybe you only need zone info about some zones, or for recent history etc. For locales/formatting, if the addons are too big, the js-joda team suggest using the native Intl api https://js-joda.github.io/js-joda/manual/formatting.html
Quite a long answer! I guess more of this needs documenting and if there are many potential users put off by size that's interesting to hear about - and even more so if they're motivated to put in effort into developing solutions to get it within their size budgets.
I only meant to make you aware of some of the utils in the Closure Library which would definitely cover some of the libs use-cases at a fraction of the code cost.
Code size is still important in pretty much all environments. Download size may be less important in non browser envs but you still care about your app starting fast and consuming less memory.
I had not watched your talk before but now I have and it is clear that you did consider using the Closue Library and chose not to use it.