As per Wikipedia Source:
Minified source code is also very useful for HTML/CSS code. As an example, successive whitespace characters in HTML/CSS are rendered as a single space, so replacing all whitespace sequences with single spaces can considerably reduce the size of a page.
If you are using Maven for your build process, then you can use Minify Maven Plugin which is a wrapper above the YUI Compressor and Google Closure Compiler but has a layer of abstraction around these tools which allows for other tools to be added in the future.
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.4</version> <configuration> <warSourceExcludes>/styles/*.css,/scripts/*.js</warSourceExcludes> </configuration> </plugin> <plugin> <groupId>com.samaxes.maven</groupId> <artifactId>minify-maven-plugin</artifactId> <version>1.7.2</version> <executions> <execution> <id>minify</id> <phase>process-resources</phase> <goals> <goal>minify</goal> </goals> <configuration> <charset>utf-8</charset> <jsEngine>CLOSURE</jsEngine> <skipMerge>true</skipMerge> <nosuffix>true</nosuffix> <cssSourceDir>styles</cssSourceDir> <cssTargetDir>styles/minified</cssTargetDir> <cssSourceIncludes> <cssSourceInclude>*.css</cssSourceInclude> </cssSourceIncludes> <jsSourceDir>scripts</jsSourceDir> <jsTargetDir>scripts/minified</jsTargetDir> <jsSourceIncludes> <jsSourceInclude>*.js</jsSourceInclude> </jsSourceIncludes> </configuration> </execution> </executions> </plugin>
script/category-app.js –> 636 B
script/jquery.js –> 273199 B
styles/style-foundation.css –> 44659 B
After the Maven build, the minified versions of JavaSript and StyleSheet files weighed as noted below:
script/category-app.js –> 256 B
script/jquery.js –> 94689 B
styles/style-foundation.css –> 37016 B
For more detailed information, please click here.
By : Nataraj Srikantaiah