The 80/20 Rule in Performance Work
You'll learn how focusing on the small portion of code that actually causes slowness yields the biggest performance gains.
The Core Principle
The 80/20 Rule (also called the Pareto Principle) states that roughly 80% of your application's execution time is spent in just 20% of your code. Sometimes it's even more extreme—90% of the time in 10% of code, or 95% in 5%.
This means that most of your codebase has minimal performance impact. The real wins come from finding and optimizing that critical 20%.
Why This Matters
Without profiling, developers often optimize the wrong things. You might spend hours refactoring a helper function that runs once per page load, while ignoring a loop that processes thousands of items. The helper function feels "messy," but the loop is where users actually wait.
How to Apply It
- Measure first (using
performance.now(), DevTools, or profiling tools you've learned) - Identify the hot paths—functions or loops consuming the most time
- Focus your optimization efforts there
- Ignore everything else until measurements prove it matters
An Analogy
Imagine your app is a store where customers spend money. Would you reorganize the clearance aisle (rarely visited) or optimize the checkout line (where everyone waits)? Performance work is the same: find where time is actually "spent."
Key Takeaway: Optimization without measurement wastes time. Profile to find the critical 20%, then optimize there for 80% of the gains.