Xhtml_compress in Plone is useless

until yesterday I was sure some magic happened on portlets before rendering to make their code smaller and faster; I was wrong:

this is what you find on all portlets code in Plone since many years:

from plone.app.portlets.cache import render_cachekey
from plone.app.portlets.portlets import base
from plone.memoize import ram
from plone.memoize.compress import xhtml_compress

class Renderer(base.Renderer):

    _template = ViewPageTemplateFile('foo.pt')

    def render(self):
        return xhtml_compress(self._template())

this is how xhtml_compress looks like:

the fact is Plone don't depend on slimmer; my I ask why?

I think compressing the HTML output is useless anyway since in most production setups the entire page is compressed using gzip by plone.app.caching. What do you think?

never use GZip compression from plone.app.caching in production for big sites; if you're going to use GZip, do it in the frontend web server as is faster and more efficient.

the GZip vs. minify argument seems to be old, but it worths minifying before compressing as you can get an additional gain according with many of the answers here:

also, your data structures will be smaller in memory and that means less instance restarts.

anyway, seems slimmer only takes care of whitespaces and we could get an additional gain by getting rid of comments also.

it would be nice if we can enable something like this as the output of ZPT with an environment variable.

Removing old cruft is probably way better than removing some whitespace that then anyway gets gziped by the frontend HTTP server...

I will gladly review a pull request removing this xhtml_compress :slight_smile:

1 Like

I'll open an issue and wait for the opinion of others then: