微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

将您的HTML,CSS和Javascript细化为一个坏主意?

维基百科 defines minification作为…

[…] the process of removing all unnecessary characters from source code without changing its functionality. These unnecessary characters usually include white space characters,new line characters,comments,and sometimes block delimiters,which are used to add readability to the code but are not required for it to execute.

为了节省带宽,我目前正在做这些工作,但有人告诉我,当某些标签(即ul和li项目)之间没有空格时,他会记得浏览器的行为不正确.这是真的?

在处理最小化的代码时,是否有任何值得注意的浏览器,代理或其他用户代理行为不当?

除了在查看源代码时丢失可读性,还有其他缺点吗?

解决方法

someone told me that he remembers a browser misbehaving when there’s
no white space between certain tags (namely ul and li items). Is this
true?

是的,在某些情况下,就像元素被设置为显示内嵌块或内联一样.

以下两个列表将呈现不同的原因,因为< li>之间的空格内容

HTML

<ul>
    <li>simple</li>
    <li>list</li>
</ul>

<ul><li>minified</li><li>list</li></ul>

CSS

li {
    display: inline-block;
    background: blue;
    color: white;
}

渲染输出

http://jsfiddle.net/Uwv3e/

原文地址:https://www.jb51.cc/html/230478.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐