3 ms·
I'm interested in learning more about how to optimize JavaScript programs. Do you know of any good examples or other resources in this area?
by euiq 4y ago
I'm interested in learning more about how to optimize JavaScript programs. Do you know of any good examples or other resources in this area?
- leeoniya 4y agonothing specific, just do a google search. generally i think advice that will always be applicable: - learn and use a profiler before there are performance issues, not after (dont treat performance as an afterthought). - internalize which patterns are faster and which are slower, and when it matters. - for any runtime with a GC, reduce repetitive memory allocation and GC pressure. prefer shallow structures. mutation instead of immutability (thus, mem allocation). - cache/memoize whenever possible. - don't use algorithms that scale poorly with data size. finally, beware of following any performance advice older than 6 months; JITs advance constantly, so make sure to re-bench/measure continuously to avoid doing unnecessary refactors, and test with real code; there are lies, damned lies, and micro-benchmarks.