Angular Should I use the vendorChunk in production

Devs say that in production vendor.js will "often get different vendor chunk hash even when changing application code only". Thus looks like there is no much use for vendorChunk=true in production. (Can't check it though)

But I've just checked budle sizes for our production app, for vendorChunk=false
main.js (1'996'389 bytes)

For vendorChunk=true
main.js (193'223 bytes) + vendor.js (1'804'540 bytes) = 1'997'763 bytes

We win 1374 bytes, that is nothing, but could depend on app of course. As for me I think its better to stick to default behavior. (true for dev, false for prod)


It depends on your use case.

The advantage of not having a separate vendor chunk is that you'll be able to get a smaller bundle size. How much smaller depends on your app. I suggest trying a build with and without the flag to see if there is a significant difference.

On the other hand, the main advantage of having vendorChunk enabled is that the users will be able to only download the changed client code without the third party code(Which are less likely to be changed often).

In summary:

Set vendorChunk to true if:

  • You plan on updating the client code often without changing much of the third party libraries.

Set vendorChunk to false if:

  • There is a significant bundle size reduction by doing so
  • OR You are unlikely to change client code frequently

I was searching by the same question, and in Angular docs https://angular.io/cli/build, says that option should only for dev.

enter image description here

Tags:

Angular