r/javascript • u/No-Onion-8207 • Mar 20 '22
A real-world example of Improving JavaScript performance
https://www.the-koi.com/projects/an-practical-example-on-improving-javascript-performance/2
u/iamnearafan Mar 29 '22
I know it's not applicable to all use cases but I recently used Redis cache to improve the speed of my site's time to first byte by about 95%. If it's useful I can share it, but you can have an essentially real time Redis cache that can help improve backend Javascript performance massively. Obviously uses a lot of memory sometimes though.
1
u/No-Onion-8207 Mar 29 '22
That sounds amazing! ๐ I will try it also for my project ๐ does redis also work for Frontend js?
1
u/iamnearafan Mar 29 '22
You'd have to use a server side rendered website for this to work. If you're using a framework, it's harder. The idea is that on the server side, you often do a lot of processing. With Redis, you can save all the output of the process and skip the processing altogether if a cached version exists. I wrote about it here if you're interested.
15
u/realPubkey Mar 20 '22
Tldr; use flat clone instead of deep clone
11
u/Nullberri Mar 21 '22
It's maybe sillier than that.
use deepclone when you actually need it, if you don't need a deep copy you can use a shallow clone.
2
u/lamb_pudding Mar 20 '22
Decent article but that site has too many ads.
1
u/No-Onion-8207 Mar 21 '22
Thank you for your feedback, Iโm currently A/B testing googles auto ads feature and I also think that it is putting to much ads on my site.
3
2
12
u/Nullberri Mar 20 '22 edited Mar 21 '22
Seems like most of the article was "I used the wrong tool for the job and didn't understand my needs very well"
was there a way to design your setup without needing a circular reference? What if you really did need to deep clone because the values get modified later and need fresh copies? How would you have resolved the design choice?
What drove your design decision to use deepclone in the first place? was their originally a need that then dropped later?