Question

I have a cherrypy web server that uses larges amounts of HTML data. Is there anyway in Python to minimize the HTML so that all comments, spaces, ext, are removed?

Was it helpful?

Solution

Not what you mean, but: Gzip. (Assuming you aren't already serving through a compressing front-end.) Compression will zip away whitespace to almost nothing; unless you have excessively large comments this will be more effective than minification.

OTHER TIPS

there are bindings to tidy for python, called mxTidy from eGenix (Marc André Lemburg)

HTML Tidy's libtidy doesn't seem to have python bindings (bit it does have perl and c++ etc), but ought to be easy to run as an exe in a pipe.

Or ideally, use it to 'tidy' all static html files once so they don't need to be tidied each time they are served.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top