question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Compression of HTML template output

See original GitHub issue

It 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:open
  • Created 3 years ago
  • Reactions:3
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
re-thccommented, Dec 29, 2020

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.

1reaction
MarkusAmshovecommented, Sep 19, 2020

Yes, I checked out the master branch and ran my templates against the trimming and the output was as I expected it to be 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found