When trying to improve performance the most important and valuable step in the process is identifying and diagnosing bottlenecks. You can attempt to guess at how to write high-performance code from the start, and to a small extent that can help, but with the complexity of the web ecosystem today that is very unlikely to be sufficient. There are just too many layers and components in the system to always get it right. So inevitably you will run in to performance bottlenecks.
When your application is not performing as you would like or expect, what can you do? What follows is my general approach to solving performance bottlenecks with a focus on React specific tools. There is an element of creativity to the process though so you should take this more as a guide and not something set in stone. You can start here but also try to find what works best for you.
There are six main steps to solving performance bottlenecks, with some parts done in a cycle:
These are the six main steps I use to solve performance bottlenecks:
* Describing the performance issue
* Describing the performance bottleneck
* Measuring the issue
* Measuring the bottleneck
* Identifying the source of the problem
* Identifying the source
* Diagnosing the cause
* Diagnosing the cause
* Generating possible solutions
* Generating possible solutions
* Selecting and implementing a solution
* Selecting and implementing a solution
* Measuring the issue again
{width: "90%", caption: "Figure 1: Tree of components"}
![Figure 1: Tree of components](./images/bottleneck-process.png)
As you can see in Figure 1, I use them in a cycle centered around measuring the bottleneck. Having some way to measure the bottleneck is extremely important. Without measuring you will not always be able to tell if the changes you made in the cycle had any effect.