Comments weigh?

22

Reviews weigh?

I leave comments throughout my code, will influence something on the site?

I'm saying more specifically in HTML, CSS, JavaScript, PHP.

    
asked by anonymous 19.04.2017 / 14:04

3 answers

20

Weigh to weigh. But you probably use a minifier , right? Then they disappear and no longer weigh.

They would weigh if they were present because it is more content to traffic not only slightly increasing the waiting time of the user but also consuming bandwidth that someone has to pay. It may not be much, but if you serve millions of pages it makes a difference. Processing on the client also weighs as all of this needs to be interpreted. But it is tiny because it will only weigh in the initial phase of interpretation that is already a very low consumption.

In PHP also weighs by interpretation, each character has to be interpreted. But also after doing parsing has no more weight.

Then use comments where you really need them to make it easier to understand and then minify to get that ridiculous weight. But first make a readable code that will almost require no comments.

There is a myth that good code is code full of comments. It's actually the opposite of this. The more comments, the more the code is bad. Of course you have to in case the comment is necessary because it can not be to express all the complexity of a problem in code. In general comments should tell you why and not what you are doing. If you have to type what, change the code to be more readable.

Read:

19.04.2017 / 14:25
3

Each character contributes to the weight of the file, but to negatively influence performance, you have to write a lot, so please comment freely. The comments are a lot of help when we keep the code. Visually they do not influence the site or system, they do not appear.

    
19.04.2017 / 14:21
3

Having HTML as the basis for sure will weigh, but it can be an insignificant difference.

You can use some preprocessor to compress your site before sending it to production, so Script will remove all comments.

Depending on the maturity of your application this is not necessary because you will be worrying about something that in practice does not bring visible results to the user. Because the difference in the end will be a few kb, or even that.

    
19.04.2017 / 14:19