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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -