Reputation: 1453
everyone. I got a dump question , please help.
I create a single page web-app, with marionette , require.js , and the backend is nodejs+mongodb. On the front end , I split the app as one view per file, one model per file and so on. As the app grow big, I got 50+ JavaScript files for this app. Which means, every user hit my site first time will have to down load them with 50+ http requests, this is crazy, isn't it?
So here comes the idea, I want combine all of these files into one, and make it through the google closure compiler, let user's browser relax a bit. But , all dependencies are managed by require.js , so I don't know is it possible to make this real happened.
Any ideas?
Upvotes: 0
Views: 91
Reputation: 7719
RequireJS ships with support to combine/optimize modules into a single file and has support for Closure Compiler. This [optional] optimization step is one of the claimed advantages of using RequireJS and is provided tooling. It can further be paired down with Almond.
RequireJS has an optimization tool that does the following
- Combines related scripts together into build layers and minifies them via UglifyJS (the default) or Closure Compiler (an option when using Java).
- Optimizes CSS by inlining CSS files referenced by @import and removing comments.
Upvotes: 2