开发者

Optimize websites by removing code comments?

I wonder if there is any (noticeable) performance improvement when rem开发者_如何学编程oving code comments from .php, .js, .css, .html, and similar files?


Mostly not, modern CPU's are very fast... The most notable improvement is the speed in the download speeds. Strip out any unnecessary comments sent down the wire to the browser, minify CSS, JavaScript files, use CDN's etc.


It depends how many comments there are.

In general though, most developers have a live version of all their code that is compressed- no whitespace outside of text formatting, no comments, etc. And an offline version that is developer-friendly with all the extra formatting and so on.

Another thing to note is with '//' style comments, they won't really hinder performance since the parser skips straight to the next line. With /**/ comments, the parsers has to keep reading all your comments until it encounters the closing */ so its ever-so-slightly more cpu intensive.

Paragraph 2 though, imo. :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜