0

From what I understand, React lazy will split your bundle into multiple files. Let's say I use lazy loading with React.router. If our server is set up to send the whole bundle through a GET request, how does React.router incrementally get the files from the server? Wouldn't it have to receive this whole bundle regardless?

1 Answer 1

1

React router runs on server-side; server does not "send" resources except when the client asks for it. All that lazy loading does is spread out the client's request to the server. The server cannot send the whole bundle through a GET request because, eg, if the client requested the script for one page, and you sent the entire bundle, the entire bundle would run multiple times and everything would be a mess.

TLDR code splitting runs on the client, not the server.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.