E
E
Evgeny Zalivadny2021-01-13 23:45:14
React
Evgeny Zalivadny, 2021-01-13 23:45:14

How to load part of a React bundle only when following a route?

Let's say in my application there is a page with a resource-intensive calculator. How to optimize the build so that this calculator is collected in a separate file and not loaded along with the main js file until it is requested by explicitly going to its page?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
iBird Rose, 2021-01-13
@Nordihan

https://ru.reactjs.org/docs/code-splitting.html#co...
see section "Code splitting based on routes"

E
Egor Zhivagin, 2021-01-14
@Krasnodar_etc

Webpack itself knows how to beat the code into chunks quite well. You can google for the name of the splitChunks option, I think

H
HohSkiller, 2021-01-15
@HohSkiller

With React Lazy

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question