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?
3 Answers
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.
Comments
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.
1 Comment
Andrea Ambu
That page links to a TidyLib Python wrapper: utidylib.berlios.de but I don't know if it minifies.