Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Compress/Minify the HTML page ( not the js and css which can do by GZIp)

ebin_Aby
Level 3
Level 3

I intend to compress/Minfy my HTML output so that the html size becomes less which increases the performance . 

 

eg : view-source:https://docs.adobe.com/content/help/en/experience-manager-dispatcher/using/getting-start... 

lots of white space if you see the source code . 

 

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution
Nirmal_Jose
Correct answer by
Community Advisor
Community Advisor

Hi @ebin_Aby ,

 

HTML compression needs to be implemented on your web server. If its Apache, you can use mod_deflate module. Please follow [1] for steps and [2] for documentation

 

[1] - https://knackforge.com/blog/karalmax/how-enable-gzip-compression-apache

[2] - https://httpd.apache.org/docs/2.4/mod/mod_deflate.html

View solution in original post

0 Replies
vanegi
Employee
Employee

You can strip whitspaces in HTML with something like htmlcompressor [0].

 

[0]:https://code.google.com/archive/p/htmlcompressor/

vanegi
Employee
Employee

To add to this, the overhead of doing whitespace compression is much bigger than the gain of just enabling gzip compression on the non-minified content. Gzip is pretty good in compressing spaces as well. More at https://www.peterbe.com/plog/html-whitespace-compression and [0]​. Even so, some HTML elements should not be stripped from whitespace (see Collapse Whitespace [1]).

 

[0]: https://stackoverflow.com/questions/7115217/any-reason-not-to-strip-whitespace-in-html

[1]: https://www.modpagespeed.com/doc/filter-whitespace-collapse

Vaibhavi_Gowda
Community Advisor
Community Advisor

Hi @ebin_Aby 

AEM OOTB doesn't have default option to minify html. 

Minification option is available for css /js by default . 

 

If you need to minify html output, you need to use html compression library which is custom implementation. 

There are many plugins are available to achieve the minification of html. One of the simplest is 

maven  html compression tag library, which you can import and use it for html minification. 

https://mvnrepository.com/artifact/com.googlecode.htmlcompressor/htmlcompressor/1.4

Or 

You can achieve the same towards apache layer as well. mod-pagespeed is one of the plugin which includes minification/compression of html along with other features which contribute to page performance. You can find more details in below article. 

https://www.modpagespeed.com/doc/build_mod_pagespeed_from_source

Nirmal_Jose
Correct answer by
Community Advisor
Community Advisor

Hi @ebin_Aby ,

 

HTML compression needs to be implemented on your web server. If its Apache, you can use mod_deflate module. Please follow [1] for steps and [2] for documentation

 

[1] - https://knackforge.com/blog/karalmax/how-enable-gzip-compression-apache

[2] - https://httpd.apache.org/docs/2.4/mod/mod_deflate.html

View solution in original post

Arun_Patidar
Community Advisor
Community Advisor

I don't think so, removing whitespaces would make much difference in performance. If you have large pages in sizes then it may but for small pages, it may not.