What is route based code splitting?

Posted by Jessica Taylor | Updated on

What is route based code splitting?

One of the best place to do code splitting is with routes. The entire page is going to re-render at once so users are unlikely to interact with other elements in the page at the same time. Due to this, the user experience won’t be disturbed.

Let us take an example of route based website using libraries like React Router with React.lazy:

In the above code, the code splitting will happen at each route level.


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers