Reputation: 321
I see more and more pages (eg. translate.google) where the html code is formatted in one line? Is it made to shorten the loading time? Is it the state of the art now?
Thanks
Upvotes: 5
Views: 687
Reputation: 40717
Just to add up (you've got great answers answers already):
If you want to be state of the art in web performance here is a fantastic resource.
Yahoo's Best Practices for Speeding Up Your Web Site
Good luck!
Upvotes: 2
Reputation: 168685
The short answer is Yes: it reduces the size of the download.
Even if that doesn't have much impact on the download speed for the individual user, if the site is serving pages to a lot of users, then the cumulative effect is a significant reduction in the amount of traffic their server has to send.
It's pretty easy to strip the redundant white space out of a HTML document, so it would probably have been written with the white space in-tact during development, and then removed afterward when it was deployed to the live system.
You'll find that Javascript and CSS files are often given the same treatment as well.
As an end user, you shouldn't have any need to look at the raw HTML. If you really want to see how the page is written, don't look at the source, rather look at the DOM - ie the tree view of the elements in the HTML page (for visual purposes; the DOM is a lot more than this, but that's what you can see)
You can see this using Firefox's Firebug extension, or the Developer Tools feature in IE8, Chrome or Safari.
Hope that helps.
Upvotes: 3
Reputation: 212875
HTML is for browsers. They don't need extra newlines/spaces people need.
If HTML is generated in a program, it needs extra time/code to format HTML readable for humans. So it is easier to output it in one line.
Upvotes: 6