2

I know little bit about webpack, but can not find a simple answer to my question. What does code splitting with Webpack mean?

Is it creating individual bundle js files for different routes and performing ajax operations for getting these js files when requested by the client.

Or is it performing async calls for getting other individual js files from server after showing the first requested page properly after the first hit?

Before I learn how to do, I would like to have an idea about what I am learning. Webpack docs doesn't help at all. It assumes you fully understand how webpack works.

4

1 回答 1

3

代码拆分将您的应用拆分为多个捆绑的 js。例如,如果您的应用程序有一个管理员部分,您的用户永远不会看到您可以将其拆分为 2 个捆绑包,这样用户就不会下载与管理员相关的 js。

捆绑js的实际加载是通过脚本标签注入来完成的。

何时应该完成实际加载由路由器处理。如果您使用的是 react-router,这是一个简单的示例

希望这会有所帮助。

于 2016-04-20T14:14:26.323 回答