How to use the uglify-js.uglify.ast_squeeze function in uglify-js

To help you get started, we’ve selected a few uglify-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github irinc / ixf / build / build.js View on Github external
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();
}
github bengourley / minj / lib / minj.js View on Github external
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();
				}

			});
github WolframHempel / photobooth-js / build / build.js View on Github external
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);
};
/**
github krasimir / assets-pack / lib / pack.js View on Github external
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
github mosen / buildy / lib / buildy / tasks / uglify.js View on Github external
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);
    }
}
github ServiceStack / Bundler / tests / Bundler.Mvc / bundler / bundler.js View on Github external
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;
}
github zythum / youkuhtml5playerbookmark / 2.0 / combinelite.js View on Github external
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!----');
	});
});
github mape / connect-assetmanager-handlers / lib / handlers.js View on Github external
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) {
github TBEDP / datavjs / bin / build.js View on Github external
exports.minify = function (input) {
  var ast = uglify.ast_squeeze(uglify.ast_mangle(parser.parse(input)));
  return uglify.gen_code(ast);
};
github ServiceStackApps / SocialBootstrapApi / src / SocialBootstrapApi / bundler / bundler.js View on Github external
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;
}