相关疑难解决方法(0)

压缩/缩小动态html

我正在使用django模板,为了便于阅读,我的html看起来类似于以下内容:

{% if some_variable %}
    text
{% else %}
    nothing exists here
{% endif %}

{% for item in set %}
    {% if forloop.first %}
...etc...
Run Code Online (Sandbox Code Playgroud)

它在运行时转换为以下html,其中包括大量的空格和返回:

text

<div>

  <li

        class='some_class

    >

    some text

   </li>

</div>

etc...
Run Code Online (Sandbox Code Playgroud)

在查看页面源时,有些页面甚至可以运行~3,000行html.

有没有工具在运行时压缩这个HTML?如何删除额外的换行符?

html compression django gzip

11
推荐指数
1
解决办法
6205
查看次数

标签 统计

compression ×1

django ×1

gzip ×1

html ×1