Compacting/minifying dynamic html

前端 未结 6 1167
梦如初夏
梦如初夏 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:41

    "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."

    I had a need to do this some time ago to increase performance and decrease latency. I wrote a template minimizer that will minimize the HTML, CSS, and Javascript in your templates beforehand so that the pages are composed minimized. It integrates into Django as a Django command, understands the intricacies of the Django tempting language, and is extendable. You can find it on pypi at the link below:

    django-template-minimizer

提交回复
热议问题