I have my JavaScript code split into few files, all using the module pattern (updating one global variable, say MyApp, with new features and members.
Will it be possible to minify the files into one and not spoiling the scopes
Example I want to minify:
File1.js
var Module = (function(ns) {
ns.fun1 = function() { alert('fun1'); };
return ns;
})(Module || {});
File2.js
var Module = (function(ns) {
ns.fun2 = function() { alert('fun2'); };
return ns;
})(Module || {});
cat one.js two.js three.js | uglifyjs -m -c -o out.min.js
– Photosynthesisuglifyjs
application, could you post an answer showing what's the resulting code? Perhaps it's the same as Google Closure's? – Caulisnpm install -g uglifyjs
, then it should be available system-wide. If you're on Windows install a better console, or just install git. – Photosynthesis