Last active
January 8, 2021 19:00
-
-
Save sskylar/7557528 to your computer and use it in GitHub Desktop.
Simple HTML minify with Liquid/Siteleaf. Strips all line breaks, tabs, and extra spaces.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% capture html %} | |
<html> | |
... | |
</html> | |
{% endcapture %}{{ html | strip_newlines | replace:' ','' | replace:' ','' | replace:' ',' ' }} |
@agriboz whoa, a blast from the past. Now that prettier is a thing I don't really concern myself with these types of problems. Since 2015 there are many good html parsers and I wouldn’t recommend relying on liquid to do anything of the sort.
https://github.com/ikatyang/angular-html-parser/tree/master/packages/angular-html-parser
I say, move nonsense like this to a build step. Also, minifying HTML isn't really a big deal. I mean if you’re nutty about perf you’ll likely need to invest some time into learning how to minify HTML with a webpack, rollup, gulp task (or whatever Ruby alternative).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@mattmischuk that's the case right.