1

I have an express.js application, it renders pages on server and serves them on different routes - /home and /dashboard etc., for example, I use several js files, some on all pages, some not:

on home page I use: jquery.js, underscore.js, somemodule1.js, somemodule2.js

on dashboard: jquery.js, underscore.js, but somemodule3.js, somemodule4.js

I need to optimize an app, 'cause I don't want to include files on every html separately..

I need somehow to merge jquery and underscore in base-merged.js and other ones to home-merged.js and dashboard-merged.js. It would be nice to have them minified as well.

Do you now node.js module or maybe grunt plugin for that? The thing I've found - https://npmjs.org/package/merge-js but not sure this will work, I also tried to configure https://github.com/yeoman/grunt-usemin plugin with no luck..

Thanks!

Kosmetika
  • 20,774
  • 37
  • 108
  • 172
  • You can use [uglify.js](https://npmjs.org/package/uglify-js). You can also try [grunt-minified](https://npmjs.org/package/grunt-minified) and [express-uglify-middleware](https://npmjs.org/package/express-uglify-middleware). – fardjad Oct 02 '13 at 22:15

1 Answers1

-1

Yes, by using one single minified js file you can easily achieve it.

You may try to use grunt-minified

warchimede
  • 878
  • 6
  • 7
kiran
  • 190
  • 1
  • 1
  • 13
  • no, I don't want to use one minified file for all hmtl pages. as you can see I need several merged and minified js files for separate pages.. – Kosmetika Oct 03 '13 at 06:53