Performance of toLocaleString is slow, due to lack of caching.
See original GitHub issueProblem
The performance cost of toLocaleString
becomes a significant bottleneck when formatting hundreds of dates, e.g. for presentation in a list or grid view. In our case, which is a react app that continously polls for data, this is resulting in significant jank when scrolling.
Root cause
Profiling the code, the root cause seem to be that Luxon instantiates a new Intl.DateTimeFormat
every time toLocaleString
is called, which has a relatively high cost.
Suggested solution
Since there will only ever be a very limited number of formats, those format instances should be cached after creation. This reduces the runtime of toLocaleString
cost by a factor of 10.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
1514851 - Number.prototype.toLocaleString is slow
This has real-world consequences: toLocaleString is so slow that using it in about:memory caused serious performance problems (bug 1517354) that were ...
Read more >Why Your Cached JavaScript Is Still Slow and Incurs ...
JavaScript, even if Cached, has significant cost on an end user's device; we'll discuss Disk, Parse, Compilation, IPC, and Bytecode Loading.
Read more >Another Front-End Framework? Here's Why You Should Give ...
These two factors alone make it appealing, but it also invites bad practice and can lead to a disastrous stack with lack of...
Read more >Untitled
Performance dance tops, Lake texoma party, Caldasia unal, Chuan-kwang, ... Club rentistas uruguay pagina oficial, Jquery tolocalestring format, ...
Read more >REST API Design Best Practices Handbook – How to Build a ...
Inside the Controller we'll be handling all stuff that is related to HTTP. ... Use data caching for performance improvements.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Released in 1.4.6. I got an 85x speedup on
toLocaleString()
awesome, thanks a bunch!