private String compressJavascriptEmbedded ( final String uri , final String code ) { if ( code == null || code . isEmpty ( ) ) { return code ; } int index = uri . lastIndexOf ( ' ' ) ; String name = uri ; if ( index > 0 ) { name = uri . substring ( index + 1 ) ; } List < SourceFile > externs = Collections . emptyList ( ) ; List < SourceFile > inputs = Arrays . asList ( SourceFile . fromCode ( name , code ) ) ; CompilerOptions options = new CompilerOptions ( ) ; CompilationLevel . SIMPLE_OPTIMIZATIONS . setOptionsForCompilationLevel ( options ) ; com . google . javascript . jscomp . Compiler compiler = new com . google . javascript . jscomp . Compiler ( ) ; Result result = compiler . compile ( externs , inputs , options ) ; if ( result . success ) { return compiler . toSource ( ) ; } throw new IllegalArgumentException ( "Unable to compress javascript" ) ; }
Compress the Javascript .