将您的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/

相关文章

vue阻止冒泡事件 阻止点击事件的执行 &lt;div @click=&a...
尝试过使用网友说的API接口获取 找到的都是失效了 暂时就使用...
后台我拿的数据是这样的格式: [ {id:1 , parentId: 0, name:...
JAVA下载文件防重复点击,防止多次下载请求,Cookie方式快速简...
Mip是什么意思以及作用有哪些