JavaScript Blazingly FAST! Lessons from a Game Engine
summary
Open-source Excalibur.js proves web games can hit low-latency targets: recursive fib(40) falls from ~2.5s to near-instant with memoization, C-style loops beat functional forms (58ms → single-digit over 5M items), and cache-coherent memory access yields ~7x speedups. Tooling is Chrome/Firefox DevTools, heap snapshots and node inspect; multi-threading uses web workers and postMessage with transferables (8MB ArrayBuffer becomes 0 in main thread after transfer). Memory fixes use scratch variables and pools/arenas; consider Excalibur.js techniques, WebAssembly for stable heavy math, and benchmark on a stable machine.
AI-written summary · about
chapters (29)
- 0:00JavaScript performance challenges
- 1:14Why JavaScript can be fast
- 3:01Cost of slow JavaScript
- 4:05Optimization principles and trade-offs
- 6:33JavaScript engine optimizations
- 9:24Profiling with DevTools
- 11:10Visual tricks for performance
- 11:31Data structures and caching
- 13:23Multi-threading with Web Workers
- 16:33Transferable objects
- 18:43SharedArrayBuffer security
- 19:47Optimizing loops
- 23:39Data-oriented programming
- 25:49Collision detection structures
- 26:33Co-routines for computation
- 27:58WebAssembly benefits
- 31:51GPU acceleration with WebGPU
- 33:38Memory management in JS
- 35:24Common memory leaks
- 38:13Heap snapshots debugging
- 40:23Closures and memory leaks
- 41:47Framework memory leaks
- 42:52Memory thrashing impact
- 44:38Object pooling
- 46:43JIT compiler optimizations
- 49:34Hidden classes in V8
- 51:24Preventing JIT deoptimization
- 52:49Benchmarking and regression
- 54:15Final thoughts and resources
related talks
19mLessons learnt pushing browsers to the limit
30mNative Speed on the Web: JavaScript and asm.js
40mHow to Improve JavaScript Performance
29mExtreme JavaScript Performance
23mOptimizing HTML5 Games: 10 Years of Learnings
30mJavaScript Taking Both the High and Low Roads
24m10 things I learned making the fastest JS server runtime in the world
31mMake coding fun: developing a game in the browser
