FR: Option to minify HTML
I think it would be nice to have an option to minify the HTML before StatCache saves it to the file system. Even with GZIP enabled, Google Page Insights still wants HTML to be minified.
I might take a crack at whipping up a PR for this. It doesn't look like MODX ships with an HTML minifier so I was looking at PHPWee: https://github.com/searchturbine/phpwee-php-minifier
MODX ships with min by Mr Clay /manager/min
I've written a plugin to minify Resource HTML output inc. inline CSS and JS. The resulting minification is written to statcache.
Originally I tried PHPWee but had issues that looked like character encoding was messed up. Can't remember exactly what was involved but at the time thought it best to stick with the bundled tool rather than add another dependency.
Let me know if you want a look at the code and I'll dig it out.
@chrisdempsey I'm looking to minify HTML. Not CSS and JS. Does min by Mr Clay minify HTML? Doesn't seem to.
It would be great if you could share your minification plugin! I think I've got the PR just about ready, aside from the actual minification itself.
Mr Clay's tool does HTML as well as css/js.
Take a look at www.cubewebworks.co.uk for sample output.
Look to the final line for before/after size eg.
I'll make the code available shortly. It's about time I tried using Github properly.
Dumb question, what's PR in this context?
@chrisdempsey Cool. an example of how to minify HTML with Mr Clay's would be great. If possible I'd like to use the MODX core, even though the manager/min stuff may be removed in MODX 3.0.
A 'PR' stands for Pull Request.
The plugin allows for a self installed version of Min.
Originally I was going to use self installed but thought the plugin would be of use to others if it used the core version.
I can't figure this repository thing so here's a Gist Plugin: minify-resource-output
sweet. thanks @chrisdempsey. if you name the gist with a .php file extension it will add syntax highlighting for php
Fixed, too many distractions going on.
Let me know how you get on with the code.
Might need to release some other bits like the auto-resize image on upload to prevent clients needlessly consuming disk space by uploading 10mb files straight out of camera.