Purpose: Customize the minification process to remove comments, reduce empty spaces, and optimize attribute handling.
from htmlmin import minify
@app.after_request
def after_request(response):
if response.content_type == 'text/html; charset=utf-8':
response.set_data(minify(response.get_data(as_text=True),
remove_comments=True,
remove_empty_space=True,
reduce_boolean_attributes=True,
remove_optional_attribute_quotes=False))
return response