DEV Community

Discussion on: Lazy loading in Vue using Webpack's code splitting

Collapse
 
onekiloparsec profile image
Cédric Foellmi

So simple. I love Vue for that. One question remains open to me: when do you consider your app to be large enough to split it?

Collapse
 
tribex profile image
Joshua Bemenderfer

I generally split based on which paths I expect the user to take through the app. If there are multiple types of users, then components specific to each type of user or more common for one are split away from the main app.

Collapse
 
alexjoverm profile image
Alex Jover

I'd say there is no right answer for this. The best you can do is, when you consider it has grown and you wanna start splitting and chunking, benchmark the before and after of the splitting (first time load, initial load, navigating time...)

Said that, depends on which splitting:

  • For components, when they make sense to be lazy loaded (ej: Modals, Tooltip...)
  • Routes and Store: when you identify independent modules (ej: Products, Users management, ...) that they have not many dependencies aside from login token and so on
Collapse
 
onekiloparsec profile image
Cédric Foellmi

That's great tips, thanks a lot. Among the bazillions of things one needs to think about when building large stuff alone, this kind of comments help starts taking first decisions.