I am working on a AngularJS project. I am going to create various JS files for controlles , directives,configs and etc nearly around 200 files. So I am planning to concatenate all the files into one huge single file app.js (this file will have all modules,directives,controllers,services,config definitions concatenated from small small other JS files in some order).
Could you please let me know whether it's a good design? Is there any other way of managing huge amount of js files?
[Edit] : Sorry for giving only minimal information which caused confusion. I am not asking how to concatenate/minify JS files. My query is , there will be around 200 files and if I concatenate all into one app.js which will become too huge and try to load it in browser will it hit my performance? Is there anything wrong in doing it in this way?
Asked
Active
Viewed 1,893 times
2

JPS
- 2,730
- 5
- 32
- 54
-
possible duplicate of [Using Gulp to Concatenate and Uglify files](http://stackoverflow.com/questions/24591854/using-gulp-to-concatenate-and-uglify-files) – Alex McMillan Jul 31 '15 at 06:29
-
This is actually a common practice. You can use Gulp or Grunt to concatenate and minify all your JS files. – Bidhan Jul 31 '15 at 06:30
1 Answers
4
Have a look into development/build tools, like gulp or grunt.
Both are taskrunners that can perform build steps (like concatenation / uglification / transpiling etc).
They both have "watch" tasks that will allow you to have them running in the background, automatically performing all necessary build steps as soon as you save a file.
There are many plugins for each, to perform pretty much anything you want to do with your source code before deploying it.
EDIT
Yes this is perfectly acceptable. Usually, for production, you would minify/uglify your javascript as well. Look into browserify and using a modular approach..

Alex McMillan
- 17,096
- 12
- 55
- 88
-
Yes. This is the correct answer. Grunt or Gulp. Even Microsoft who had there own tools with ASP.Net now concede that Grunt or Gulp should be used to build Web projects. – Martin Jul 31 '15 at 06:47