Compression of HTML template output
See original GitHub issueIt would be nice to to have a setting to produce compressed ouput for HTML templates, by removing all unneeded indentations from the output.
For instance this template:
<div>
@if(true)
<span>Hello</span>
@endif
</div>
Currently produces this output:
<div>
<span>Hello</span>
</div>
With compression on, the output would be this instead:
<div><span>Hello</span></div>
This could save quite a few bytes that need to be sent to each client, plus reduces the server resources needed for rendering, if done in the template compiler.
It’s a tricky feature and things could go wrong, so it should be optional. Also, pre
and code
tags should be left as is and it would be a good idea to allow the user to specify css classes that indicate no compression.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Reduce the size of HTML, CSS, JavaScript, PHP and Smarty ...
Source; Compressed; Errors; Messages. ( expand | hide ). Compress. Compressing. Please wait... Drag a File or Paste Code. Load Only.
Read more >How to Compress an HTML File - HubSpot Blog
Learn how to compress HTML files to improve load times, ... While minification and compression deliver similar output file sizes, ...
Read more >Minify HTML outputs in Smarty - compression - Stack Overflow
I used this code: function minify_html($tpl_output, Smarty_Internal_Template $template) { $tpl_output = preg_replace('![\t ]*[\r\n]+[\t ]*!
Read more >Using HTML and HTTP Compression with Weblogic Server
Have you ever wondered about the extra spaces in your HTML output from JSP Pages or Servlets? ... It's called HTML Template Compression....
Read more >Compress Your HTML in Jekyll - DigitalOcean
Just like with CSS and JavaScript, HTML output can be compressed and minified by removing whitespace, new lines, comments and even removing ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Please include css and/or js compression if possible when you do the HTML compression. If it’s used for e.g. email templates, the assets are likely embedded.
Yes, I checked out the master branch and ran my templates against the trimming and the output was as I expected it to be 😃