plugins/minify.js
function minifyCodeGoogle(code, callback, minificationLevel, description){
    for (var i in minifyCache) {
      var item = minifyCache[i];
      if (item.code==code && item.level==minificationLevel) {
        console.log("Found code in minification cache - using that"+description);
        // move to front of cache
        minifyCache.splice(i,1); // remove old
        minifyCache.push(item); // add at front
        // callback
        callback(item.minified);
        return;
      }
    }
    closureCompilerGoogle(code,  minificationLevel, 'compiled_code', function(minified) {
      if (minified.trim()!="") {
        Espruino.Core.Notifications.info('No errors'+description+'. Minifying ' + code.length + ' bytes to ' + minified.length + ' bytes');
        if (minifyCache.length>100)
          minifyCache = minifyCache.slice(-100);
        minifyCache.push({ level : minificationLevel, code : code, minified : minified });
        callback(minified);
      } else {
        Espruino.Core.Notifications.warning("Errors while minifying"+description+" - sending unminified code.");
        callback(code);
        // get errors...
        closureCompilerGoogle(code,  minificationLevel, 'errors',function(errors) {
          errors.split("\n").forEach(function (err) {
            if (err.trim()!="")
              Espruino.Core.Notifications.error(err.trim()+description);
          });
        });
      }
    });
  }
function minifyCodeGoogle(code, callback, minificationLevel, description){
    for (var i in minifyCache) {
      var item = minifyCache[i];
      if (item.code==code && item.level==minificationLevel) {
        console.log("Found code in minification cache - using that"+description);
        // move to front of cache
        minifyCache.splice(i,1); // remove old
        minifyCache.push(item); // add at front
        // callback
        callback(item.minified);
        return;
      }
    }
    closureCompilerGoogle(code,  minificationLevel, 'compiled_code', function(minified) {
      if (minified.trim()!="") {
        Espruino.Core.Notifications.info('No errors'+description+'. Minifying ' + code.length + ' bytes to ' + minified.length + ' bytes');
        if (minifyCache.length>100)
          minifyCache = minifyCache.slice(-100);
        minifyCache.push({ level : minificationLevel, code : code, minified : minified });
        callback(minified);
      } else {
        Espruino.Core.Notifications.warning("Errors while minifying"+description+" - sending unminified code.");
        callback(code);
        // get errors...
        closureCompilerGoogle(code,  minificationLevel, 'errors',function(errors) {
          errors.split("\n").forEach(function (err) {
            if (err.trim()!="")
              Espruino.Core.Notifications.error(err.trim()+description);
          });
        });
      }
    });
  }
function minifyCodeGoogle ( code , callback , minificationLevel , description ) { for ( var i in minifyCache ) { var item = minifyCache [ i ] ; if ( item . code == code && item . level == minificationLevel ) { console . log ( "Found code in minification cache - using that" + description ) ; // move to front of cache minifyCache . splice ( i , 1 ) ; // remove old minifyCache . push ( item ) ; // add at front // callback callback ( item . minified ) ; return ; } } closureCompilerGoogle ( code , minificationLevel , 'compiled_code' , function ( minified ) { if ( minified . trim ( ) != "" ) { Espruino . Core . Notifications . info ( 'No errors' + description + '. Minifying ' + code . length + ' bytes to ' + minified . length + ' bytes' ) ; if ( minifyCache . length > 100 ) minifyCache = minifyCache . slice ( - 100 ) ; minifyCache . push ( { level : minificationLevel , code : code , minified : minified } ) ; callback ( minified ) ; } else { Espruino . Core . Notifications . warning ( "Errors while minifying" + description + " - sending unminified code." ) ; callback ( code ) ; // get errors... closureCompilerGoogle ( code , minificationLevel , 'errors' , function ( errors ) { errors . split ( "\n" ) . forEach ( function ( err ) { if ( err . trim ( ) != "" ) Espruino . Core . Notifications . error ( err . trim ( ) + description ) ; } ) ; } ) ; } } ) ; }
Use the 'online' Closure compiler
Use the online Closure compiler