HTML string interpretation and compact code
I have the following code example:
<body> <div id="a"></div> <div id="b"></div> </body> If I add blank lines between each of my source lines, for example:
<body> <div id="a"></div> <div id="b"></div> </body> does this do something for the performance of my site? Will page loading be slower?
Yes, compact code speeds up page loading due to reduced payload ... but not measurable , at least in most cases, unless your page is massive, you won't see the difference.
Pages should be delivered via gzip , which makes the size difference between spaced and unallocated insignificant, just do what you read, Congratulations on later. As with everything, you need to weigh the costs, in this case a very small difference in the size of the payload, so that it’s easiest to support for you.
Theoretically, yes.
For a server, if it should send a 1 MB file to each client, it should spend n time and resources to send this single file. Now, if you manage to halve the file size, the time and resources that will be required for each user on the server will be .5n.
For the client, he must download the file. Assuming a download speed of 25 KB / s, a 1 MB file will take 41 seconds to download. The .5MB file will take 20.5 s. This saves 20 seconds by reducing the file size.
However, in practice. No, I would not worry about this if you are not dealing with audio / video / image data. This is because the character in the HTML document is only a couple of bytes. Of course, you could say 100 extra characters that you could trim and delete - for example, spaces. At best, you’ll save another 1 KB per page.
I would not be too worried about this if you are not developing an application or solution where it should be compact. But any modern or low-power computer will not break with 1KB of additional data in their HTML file.
Page loading and compact code? yes, it really improves the job, because extra newlines and spaces are nothing more than characters that need to be downloaded to the client computer.
However, I suggest you see it as part of a great optimization strategy.
I suggest you take a look at the YSlow / Yahoo Guidelines , which will help you understand the various parts of the “strategy” that are added to the server and client components. And the collective results are amazing for large sites.