Measure long tasks, rendering cost, and retained resources.
- performance.now
- layout thrashing
- event listeners
- cleanup
JavaScript can block the main thread and delay input or painting. Measure a slow operation before optimizing it. Batch DOM changes, avoid repeated forced layout reads and writes, and remove listeners or timers when their owner is gone. Use browser performance tools to find the actual bottleneck.
Micro-optimizing a tiny loop while leaving expensive DOM work untouched rarely helps users.
Compare rendering a large list one item at a time with a batched approach under the same conditions.
Open example.html in a browser and edit example.js. Save, refresh, and use the Console and debugger to inspect values.
- Explain the core idea in your own words without reading the code.
- Change one input and predict the output before running it.
- Test one boundary or failure case, then record what you changed.