Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

To optimize or not to optimize, that is...

Status
Not open for further replies.

ChrisRChamberlain

Programmer
Mar 23, 2000
3,392
GB
Hi all

Coming from the world of OOP where copious comments and code indenting is considered best practice, it seems a pain that a webbrowser apparently requires the opposite.

The slowest elements of a page to download presumably are the images, so is there any significant gain in applying source formatting Dreamweaver style as opposed to leaving a page with code indentation and comments?

FAQ184-2483 - answering getting answered.​
Chris [pc2]
PDFcommandertm.net
PDFcommandertm.com
 
Code indentation and commenting comprises a very small percentage of the overall page weight that it's probably not a major concern for low traffic sites. Increase the page hits and you end up sending more data (because of the comments and extra whitespace).

Modern web servers can send pages using gzip compression (if the browser can support it -- which almost all do nowadays)... so those whitespaces compress to almost nothing.

Page load speed is determined by so many things including:
- well formed HTML (with closing tags) is fast to load
- use of tables (with certain content) can double the load speed (since the browser has to parse the page twice)
- images with widths and heights specified (in css or inline) are a good idea because the browsers can allocate space for them and continue parsing the page in the same phase
- using linked css and javascript instead of putting it into the page is fast to load in successive page loads
- avoid using javascript until the page DOM has loaded will speed things up some as well

Commenting is not a major part of most HTML pages - I have started putting the comments server-side so that I can see them when editing the page, but they don't show when the users view the source.

Each to their own [smile]

Cheer,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]

What is Javascript? faq216-6094
 
Ah. I see what you are saying... heh. I'll reword it:
- use of tables (with certain content) can increase the time it takes for the page to load by a factor of two (since the browser has to parse the page twice)

Cheers,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]

What is Javascript? faq216-6094
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top