-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cache toLocaleString #1236
Comments
Hi, it seems this issue does not have any visibility. We might move away from the timezone plugin for some of our hot functions, but I'd be happy to contribute back to a package that we use so extensively. It seems like the timezone plugin is the only place in the codebase where there's still usage of |
This code seems to have landed in a different form on 1.11.5? https://github.com/iamkun/dayjs/blob/dev/src/plugin/timezone/index.js#L12 Now, we continued to have issues even with that version because ends up initializing a new version of Intl.DateTimeFormat each time, per MDN docs We changed that with the following for better perf results: |
@nuria how did you expose getDateTimeFormat since it isn't exported, was it just forked or copied? |
Calls to "toLocaleString" in the timezone plugin is extremly slow:
dayjs/src/plugin/timezone/index.js
Line 99 in ed9629b
The same problem was discussed in luxon: moment/luxon#352
The solution for this performance problem is caching like they did in luxon: moment/luxon@bb77d5e
Just use Intl.DateTimeFormat instead of "toLocaleString" (it always produce the equivalent result) and cache these instances of Intl.DateTimeFormat.
The text was updated successfully, but these errors were encountered: