0

I'm trying to server js from node side which is working find, what is the best way to minify the javascript on fly?

app.get('/js/global.js', function (req, res) {
    res.render('widget/global', {
        name : 'myname'
    });
});
tomalex
  • 1,233
  • 6
  • 17
  • 40
  • Minify which javascript? – Alex Apr 07 '14 at 16:54
  • im using dust template widget/global lets say it has some variables with values from node server and some functions , i have to minify these. For Reference: http://stackoverflow.com/questions/22541851/generate-javascript-file-with-nodejs – tomalex Apr 07 '14 at 17:53
  • you should **not** "minify" on-the-fly meaning when someone sends a request you respond with the minified version of javascript.. which eventually will eat up resources if you don't use caching. Although if its only variables then why not respond with JSON instead of javascript .. – Gntem Apr 07 '14 at 18:37
  • Its more like the use case, i want to load some config from server to client side and which should be available during page load rather than ajax as most of other ajax requests depends on it. For example i'm putting api urls in server config and surfacing those values to client side by setting it as "locals" . I don't want to make this as a ajax call to get the config. – tomalex Apr 13 '14 at 00:05

0 Answers0