MEAN.js has that particular aspect covered. In fact, if you run your app using just grunt
command, the app will start running in development environment, and so the js files (either the ones from 3rd party libraries or even your custom js files) are not concatenated nor minified. This helps you while debugging. However this is clearly not good for an app in production in terms of performance.
If you use the command grunt prod
your app will start running in production mode and so your custom js files will be concatenated and mninified. 3rd party library files won't be concatenated but grunt
will use the minified version of them.
You can see which assets will be loaded for both development and production modes in config/assets/development.js
and config/assets/production.js
, respectively.
Also if you want to see what are the differences between both grunt
and grunt prod
tasks you can check your gruntfile.js
.
Note 1: The commands I mentioned about grunt
can also be used with gulp
, since MEAN.js has both a gruntfile.js
and a gulpfile.js
defined.
Note 2: If, by the time you use grunt prod
and still have so many files being loaded, that means you are using an high number of 3rd party libraries and a possible solution for that case is to concatenate 3rd party library files into a vendor.js
file however in doing that you might run into trouble, such as some libraries like AngularJS needing the files to be loaded with a specific order. You will need extra caution if you edit your gruntfile to implement such task.