HTML / CSS缩进可选,JS缩进必须吗?

时间:2022-02-12 22:30:29

So when I get HTML and CSS validated, it's not required to be indented to pass validation. However, when I get JS validated, it needs to be indented to pass. I don't indent any of my code because practically all my pages are relatively short and simple so I actually find it more effort and a waste of space to indent. However, is it especially important that I do so for JS? Is there a reason it's required for JS but not HTML or CSS?

因此,当我验证HTML和CSS时,不需要缩进来通过验证。但是,当我验证JS时,需要缩进才能通过。我没有缩进我的任何代码,因为实际上我的所有页面都相对简短,所以我实际上发现它更省力,浪费空间来缩进。但是,我这样做对JS来说特别重要吗?有没有理由需要JS而不是HTML或CSS?

1 个解决方案

#1


1  

If your code validates on everything apart from indentation then I would be totally happy with that, especially for javascript.

如果你的代码验证除了缩进之外的所有内容,那么我会非常满意,特别是对于javascript。

A lot of frameworks are moving towards bundling and minification as a way of reducing the number of http requests and the overall file size. This removes any css and javascript whitespace anyway.

许多框架正在朝着捆绑和缩小的方向发展,以减少http请求的数量和整个文件的大小。这无论如何都会删除任何css和javascript空格。

#1


1  

If your code validates on everything apart from indentation then I would be totally happy with that, especially for javascript.

如果你的代码验证除了缩进之外的所有内容,那么我会非常满意,特别是对于javascript。

A lot of frameworks are moving towards bundling and minification as a way of reducing the number of http requests and the overall file size. This removes any css and javascript whitespace anyway.

许多框架正在朝着捆绑和缩小的方向发展,以减少http请求的数量和整个文件的大小。这无论如何都会删除任何css和javascript空格。