serialize-javascript icon indicating copy to clipboard operation
serialize-javascript copied to clipboard

Option to minimize output?

Open max-degterev opened this issue 7 years ago • 4 comments

Would be nice to have an option to remove unnecessary whitespace in stringified functions

max-degterev avatar Jan 20 '17 15:01 max-degterev

Have you tried feeding the output of module into a minifier? I would suggesting looking at babili as it supports ES6+ syntax while Uglify doesn't.

ericf avatar Jan 20 '17 16:01 ericf

it would work, but would create additional overhead parsing surrounding JSON structures, best place to put minifier is here: https://github.com/yahoo/serialize-javascript/blob/master/index.js#L101

max-degterev avatar Jan 20 '17 17:01 max-degterev

I would prefer to keep this package simple and not add a minifier as a runtime dependency. Have you thought about minifying your functions/code at build time that will be serialized? If you pre-minify the function, it will offer the best perf as then it wouldn't have to happen on every single serialize() call (or after every call).

ericf avatar Jan 20 '17 17:01 ericf

Could you add another option?

GitBruno avatar Apr 18 '18 07:04 GitBruno