UglifyJs JavaScript API for JSON minification? -
so looping through files in directory via node , want minify them uglifyjs.
the api dead easy javascript files:
var uglifyjs = require("uglify-js") // looping here uglifyjs.minify(listofallfiles[i])
however, files need minify json files, producing eval error. in command line, if minifying json, pass --expr
, evaluate single expression. idea how pass options object of javascript api?
cheers.
if you're not dead set on uglifyjs, solve plain javascript, because json can't uglified much. remove whitespace, do
json.stringify(json.parse(listofallfiles[i]))
to remove whitespace.
(assuming listofallfiles[i]
json string.)
Comments
Post a Comment