Class HtmlMinifyFilter
java.lang.Object
org.springframework.web.filter.GenericFilterBean
org.springframework.web.filter.OncePerRequestFilter
org.broadleafcommerce.common.web.util.HtmlMinifyFilter
- All Implemented Interfaces:
jakarta.servlet.Filter,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.InitializingBean,org.springframework.context.EnvironmentAware,org.springframework.core.env.EnvironmentCapable,org.springframework.core.Ordered,org.springframework.web.context.ServletContextAware
@Component("blHtmlMinifyFilter")
@ConditionalOnProperty("filter.html.minification.enabled")
public class HtmlMinifyFilter
extends org.springframework.web.filter.OncePerRequestFilter
implements org.springframework.core.Ordered
Enable html minification. All unnecessary white space will be removed from html, inline CSS and inline JS. This should
serve to provide some reduction in byte size of the response. This is a suggested pagespeed optimization from Google.
The drawbacks of this filter include: a slight expense in processing the response payload, and the page response is
kept entirely in memory to facilitate processing before responding to the caller (usually the http response can be (is) pushed
back incrementally to avoid keeping the entire page contents in memory).
The filter is disabled by default. Activate by including this property declaration in your Spring environment property
file(s):
filter.html.minification.enabled=true.- Author:
- Jeff Fischer
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected com.googlecode.htmlcompressor.compressor.HtmlCompressorprotected PatternFields inherited from class org.springframework.web.filter.OncePerRequestFilter
ALREADY_FILTERED_SUFFIXFields inherited from class org.springframework.web.filter.GenericFilterBean
loggerFields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoFilterInternal(jakarta.servlet.http.HttpServletRequest httpServletRequest, jakarta.servlet.http.HttpServletResponse httpServletResponse, jakarta.servlet.FilterChain filterChain) intgetOrder()voidprotected booleanMethods inherited from class org.springframework.web.filter.OncePerRequestFilter
doFilter, doFilterNestedErrorDispatch, getAlreadyFilteredAttributeName, isAsyncDispatch, isAsyncStarted, shouldNotFilter, shouldNotFilterAsyncDispatch, shouldNotFilterErrorDispatchMethods inherited from class org.springframework.web.filter.GenericFilterBean
addRequiredProperty, afterPropertiesSet, createEnvironment, destroy, getEnvironment, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, setBeanName, setEnvironment, setServletContext
-
Field Details
-
compressor
protected com.googlecode.htmlcompressor.compressor.HtmlCompressor compressor -
pattern
-
-
Constructor Details
-
HtmlMinifyFilter
public HtmlMinifyFilter()
-
-
Method Details
-
getOrder
public int getOrder()- Specified by:
getOrderin interfaceorg.springframework.core.Ordered
-
doFilterInternal
protected void doFilterInternal(jakarta.servlet.http.HttpServletRequest httpServletRequest, jakarta.servlet.http.HttpServletResponse httpServletResponse, jakarta.servlet.FilterChain filterChain) throws jakarta.servlet.ServletException, IOException - Specified by:
doFilterInternalin classorg.springframework.web.filter.OncePerRequestFilter- Throws:
jakarta.servlet.ServletExceptionIOException
-
isWidget
-
initFilterBean
public void initFilterBean()- Overrides:
initFilterBeanin classorg.springframework.web.filter.GenericFilterBean
-