Java Code Examples for com.googlecode.htmlcompressor.compressor.HtmlCompressor#setRemoveHttpProtocol()
The following examples show how to use
com.googlecode.htmlcompressor.compressor.HtmlCompressor#setRemoveHttpProtocol() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TioHtmlCompressor.java From t-io with Apache License 2.0 | 5 votes |
/** * @param compressor * @author tanyaowu */ public TioHtmlCompressor() { super(); HtmlCompressor compressor = new HtmlCompressor(); compressor.setEnabled(true); compressor.setCompressCss(false); compressor.setCompressJavaScript(false); compressor.setGenerateStatistics(false); compressor.setRemoveComments(options.isRemoveComments()); compressor.setRemoveMultiSpaces(options.isRemoveMutliSpaces()); compressor.setRemoveIntertagSpaces(options.isRemoveIntertagSpaces()); compressor.setRemoveQuotes(options.isRemoveQuotes()); compressor.setSimpleDoctype(options.isSimpleDoctype()); compressor.setRemoveScriptAttributes(options.isRemoveScriptAttributes()); compressor.setRemoveStyleAttributes(options.isRemoveStyleAttributes()); compressor.setRemoveLinkAttributes(options.isRemoveLinkAttributes()); compressor.setRemoveFormAttributes(options.isRemoveFormAttributes()); compressor.setRemoveInputAttributes(options.isRemoveInputAttributes()); compressor.setSimpleBooleanAttributes(options.isSimpleBooleanAttributes()); compressor.setRemoveJavaScriptProtocol(options.isRemoveJavaScriptProtocol()); compressor.setRemoveHttpProtocol(options.isRemoveHttpProtocol()); compressor.setRemoveHttpsProtocol(options.isRemoveHttpsProtocol()); compressor.setPreserveLineBreaks(options.isPreserveLineBreaks()); this.compressor = compressor; }
Example 2
Source File: HtmlCompressorTag.java From htmlcompressor with Apache License 2.0 | 4 votes |
@Override public int doEndTag() throws JspException { BodyContent bodyContent = getBodyContent(); String content = bodyContent.getString(); HtmlCompressor htmlCompressor = new HtmlCompressor(); htmlCompressor.setEnabled(enabled); htmlCompressor.setRemoveComments(removeComments); htmlCompressor.setRemoveMultiSpaces(removeMultiSpaces); htmlCompressor.setRemoveIntertagSpaces(removeIntertagSpaces); htmlCompressor.setRemoveQuotes(removeQuotes); htmlCompressor.setPreserveLineBreaks(preserveLineBreaks); htmlCompressor.setCompressJavaScript(compressJavaScript); htmlCompressor.setCompressCss(compressCss); htmlCompressor.setYuiJsNoMunge(yuiJsNoMunge); htmlCompressor.setYuiJsPreserveAllSemiColons(yuiJsPreserveAllSemiColons); htmlCompressor.setYuiJsDisableOptimizations(yuiJsDisableOptimizations); htmlCompressor.setYuiJsLineBreak(yuiJsLineBreak); htmlCompressor.setYuiCssLineBreak(yuiCssLineBreak); htmlCompressor.setSimpleDoctype(simpleDoctype); htmlCompressor.setRemoveScriptAttributes(removeScriptAttributes); htmlCompressor.setRemoveStyleAttributes(removeStyleAttributes); htmlCompressor.setRemoveLinkAttributes(removeLinkAttributes); htmlCompressor.setRemoveFormAttributes(removeFormAttributes); htmlCompressor.setRemoveInputAttributes(removeInputAttributes); htmlCompressor.setSimpleBooleanAttributes(simpleBooleanAttributes); htmlCompressor.setRemoveJavaScriptProtocol(removeJavaScriptProtocol); htmlCompressor.setRemoveHttpProtocol(removeHttpProtocol); htmlCompressor.setRemoveHttpsProtocol(removeHttpsProtocol); if(compressJavaScript && jsCompressor.equalsIgnoreCase(HtmlCompressor.JS_COMPRESSOR_CLOSURE)) { ClosureJavaScriptCompressor closureCompressor = new ClosureJavaScriptCompressor(); if(closureOptLevel.equalsIgnoreCase(ClosureJavaScriptCompressor.COMPILATION_LEVEL_ADVANCED)) { closureCompressor.setCompilationLevel(CompilationLevel.ADVANCED_OPTIMIZATIONS); } else if(closureOptLevel.equalsIgnoreCase(ClosureJavaScriptCompressor.COMPILATION_LEVEL_WHITESPACE)) { closureCompressor.setCompilationLevel(CompilationLevel.WHITESPACE_ONLY); } else { closureCompressor.setCompilationLevel(CompilationLevel.SIMPLE_OPTIMIZATIONS); } htmlCompressor.setJavaScriptCompressor(closureCompressor); } try { bodyContent.clear(); bodyContent.append(htmlCompressor.compress(content)); bodyContent.writeOut(pageContext.getOut()); } catch (Exception e) { throw new JspException("Failed to compress html",e); } return super.doEndTag(); }