Weigh the cost-benefit of performance optimizations
Most performance optimizations come at a complexity cost. When adding a performance optimization, you do real-world testing to evaluate the before/after to ensure your optimization is worth the effort (and not making things worse).
Examples
- You’re considering memoizing a component that renders user profile data. Instead of assuming this will improve performance, you benchmark the rendering time with and without memoization. You find that it actually makes things slower so you investigate further and identify an issue where an object is being passed as a prop. You then switch from an object prop to primitive values and memoization starts making things perform better. However the impact on performance is negligible (even on a simulated slow device) so you remove the optimization in favor of keeping things simpler. (Alternative ending, it does make things significantly faster so you keep it).
- Your app loads a large dataset on the main dashboard. Before implementing complex data caching, you measure the load time and see that it’s manageable. You decide to prioritize features and revisit caching if the dataset grows, avoiding premature optimization that would have added maintenance costs.
Share this principle