Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
buffer = new Buffer(data);
fs.writeSync(out, buffer, 0, buffer.length);
// Write permanent comment to minified file
index = data.indexOf("/*"), lastIndex = data.indexOf("*/",index);
if(index != -1 && lastIndex != -1) {
comment = data.substring(index,lastIndex+2);
buffer = new Buffer(comment + "\n");
fs.writeSync(outMin, buffer, 0, buffer.length);
data = data.substring(lastIndex+2);
}
//Minify the code
ast = jsp.parse(data); // parse code and get the initial AST
ast = pro.ast_mangle(ast); // get a new AST with mangled names
ast = pro.ast_squeeze(ast); // get an AST with compression optimizations
minCode = pro.gen_code(ast); // compressed code here
// Write minified code to file
buffer = new Buffer(minCode+";\n");
fs.writeSync(outMin, buffer, 0, buffer.length);
}
fs.closeSync(out);
fs.closeSync(outMin);
console.log(" Output: scripts/ixf-plugins.js");
console.log(" Output: scripts/ixf-plugins.min.js");
if(callback)
callback();
}
fs.readFile(jsPath, 'utf8', function (err, str) {
if (err) {
console.log(err);
return error(err, next);
}
try {
var ast = parser.parse(str);
ast = uglifyer.ast_mangle(ast);
ast = uglifyer.ast_squeeze(ast);
fs.writeFile(minjPath, uglifyer.gen_code(ast), 'utf8', function (err) {
next(err);
});
} catch (ex) {
// Probably reached this because of invalid
// syntax in js file. Revert back to serve original
// -- let it error in the browser if need be.
req.url = originalPath;
next();
}
});
var fMinifyJs = function( sJavasScript )
{
var ast = jsp.parse( sJavasScript ); // parse code and get the initial AST
ast = pro.ast_mangle(ast); // get a new AST with mangled names
ast = pro.ast_squeeze(ast); // get an AST with compression optimizations
return pro.gen_code(ast);
};
/**
js: function(files) {
try {
var content = this.mergeFiles(files);
if(this.asset.minify) {
var jsp = require("uglify-js").parser;
var pro = require("uglify-js").uglify;
var ast = jsp.parse(content); // parse code and get the initial AST
ast = pro.ast_mangle(ast); // get a new AST with mangled names
ast = pro.ast_squeeze(ast); // get an AST with compression optimizations
content = pro.gen_code(ast); // compressed code here
}
this.output(content);
} catch (err) {
for(var i=0; i
ast, // parsed AST
uglified = "";
try {
ast = parser.parse(data, options.parse_strict_semicolons);
if (options.lift_variables === true) {
ast = pro.ast_lift_variables(ast);
}
if (options.mangle === true) {
ast = pro.ast_mangle(ast, options.mangle_options);
}
if (options.squeeze === true) {
ast = pro.ast_squeeze(ast, options.squeeze_options);
}
uglified = pro.gen_code(ast, options.options);
callback(null, uglified, filename); // Callback with uglified version.
} catch (e) {
// Uglify doesn't usually give descriptive errors if the parser fails.
callback('The minify task failed, usually this means the source file was unparseable. Please check your syntax. Exception:' + e.message);
}
}
function minifyjs(js) {
var ast = jsp.parse(js);
ast = pro.ast_mangle(ast);
ast = pro.ast_squeeze(ast);
var minJs = pro.gen_code(ast);
return minJs;
}
loopRead(function(){
var ast;
combineFile = '(function(){' + combineFile + '})();';
ast = jsp.parse(combineFile);
ast = pro.ast_mangle(ast);
ast = pro.ast_squeeze(ast);
ast = pro.gen_code(ast);
fs.writeFile('youkuhtml5playerbookmark2lite.js', ast, function() {
console.log('-----youkuhtml5playerbookmark2lite.js updated!----');
});
});
this.uglifyJsOptimize = function (file, path, index, isLast, callback) {
var ast = uglifyParser.parse(file);
ast = uglifyProcess.ast_mangle(ast);
ast = uglifyProcess.ast_squeeze(ast);
callback(uglifyProcess.gen_code(ast));
};
this.fixGradients = function (file, path, index, isLast, callback) {
exports.minify = function (input) {
var ast = uglify.ast_squeeze(uglify.ast_mangle(parser.parse(input)));
return uglify.gen_code(ast);
};
function minifyjs(js) {
var ast = jsp.parse(js);
ast = pro.ast_mangle(ast);
ast = pro.ast_squeeze(ast);
var minJs = pro.gen_code(ast);
return minJs;
}