Compacting/minifying dynamic html

前端 未结 6 1171
梦如初夏
梦如初夏 2021-01-04 12:21

I am using django templating, and for readability I have html that looks similar to the following:

{% if some_variable %}
    text
{% else %}
    nothing exi         


        
6条回答
  •  滥情空心
    2021-01-04 12:40

    I think a front-end development tool, such as grunt-contrib-htmlmin, should be used to minify Django template files before deploying them to production server.

    This way, the minification process happens in "build-time", and saves server CPU resource for HTML minification in "run-time".

    This tool is originally designed for minifying HTML, but also works for Django templates as I tried out.

提交回复
热议问题