Open berstend opened 8 years ago
Sorry been a bit busy last weeks. This plugin is still in an uncommitted repo on my harddrive. I'll try to push it to github asap.
Hi @Swaagie
How can I help? Would you like me to help publishing https://github.com/Swaagie/minimize-plugin-uglifyjs on npm (and than transfer the ownership to you)?
any updates on this? :)
What I did to get this working:
'use strict';
var uglifyjs = require('uglify-js');
//
// Unique ID to identify the plugin.
//
exports.id = 'uglifyjs';
//
// Minify the JS with uglify JS.
//
exports.element = function plugin(element, done) {
if(!element.parent || element.parent.name != 'script') return done();
var content, code
, options = uglifyjs.defaults({
fromString: true,
compress: {//unused: false <-- doesn't make any difference
},
mangle: {}
});
// 1. parse
content = uglifyjs.parse(element.data, options);
// 2. compress <-- slowest part
content.figure_out_scope();
options.compress.screw_ie8 = true;
options.compress.warnings = false;
content = content.transform(uglifyjs.Compressor(options.compress));
// 3. mangle
options.mangle.screw_ie8 = true;
content.figure_out_scope(options.mangle);
content.compute_char_frequency(options.mangle);
content.mangle_names(options.mangle);
// 4. output
var stream = uglifyjs.OutputStream();
content.print(stream);
element.data = stream.toString();
done();
};
var Minimize = require('minimize')
, jsuglify = require('./controller/thirdparty/minizime-plugin-uglify')
, minimize = new Minimize({ plugins: [jsuglify]});
tried to optimize the performance, unfortuantely it's still at least 50% slower than without a uglifyjs2.
any updates on this? :)
After a forced break from OS (mainly time restraints) this should receive updates shortly. Last week I opened a project https://github.com/Swaagie/minimize/projects/1 to track this work.
ping @Swaagie can you push the branch at least so we can help you out?
I'm interested in using minimize to compress inline JS tags as well.
Unfortunately the link to the minimize uglify npm package seems to be broken: https://github.com/Swaagie/minimize#available-plugins
I couldn't find any reference to uglifyjs in the minimize code - is compressing inlined JS snippets still supported?