Forum

Thread tagged as: Suggestions

suggestion: minify html

It would be great if perch_content(), perch_content_custom(), etc. had an option to return minified HTML (i.e. with whitespace and comments stripped).

David Newton

David Newton 0 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Agreed. I've looked at it from time to time. Keeping in mind that we can't rely on the server having things like Tiny available, we'd need to look at a pure PHP solution.

On the surface it sounds simple, but the edge cases (like <script> blocks, <pre> blocks etc) make it more of a project to undertake. Especially when you then care about performance and potentially needing to do it at runtime. I've not yet had the time available to dig into that.

Yup. I looked into it briefly and it does seem like it could get messy fast. I'm considering playing around with Minify, which has a PHP HTML minifying class. Maybe you'll find that useful, too.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, that's the one I'd bookmarked, too.