Well Commented Code Slows Your Page Load

by: Karen Scharf, Small Business Marketing

Share

Documenting your web site by using comment codes definitely helps in site maintenance tasks, especially when you have multiple programmers and designers working on the same pages. However, comment tags also cause page bloat and slow down your web page load time.

If you’ve been writing code or designing web pages for any length of time, you know how important it can be to include documentation within your JavaScript, CSS and even HTML. It’s hard to look at a script that you wrote months ago and remember exactly what your train of thought was at the time you wrote it. And if you have multiple programmers working on the same project, it can be almost impossible to eliminate comment tags altogether.

So, I’m not going to suggest you plow through all your code and wipe out any comment tags you come across. But I do have a few hints that will establish a happy medium between page load and proper documentation.

Eliminate the Duh!

First, let’s consider “proper documentation”. Many of the comment tags I come across can’t exactly be considered “proper documentation”. And, in fact, some of them are just downright dumb. Consider the necessity of all of your tags. Is <!– headline starts here –> really necessary? I mean, come one, doesn’t the <h1> tag indicate that the headline is about to start. My first suggestion is to eliminate any tag that leaves you thinking, “Well, duh!”

Reduce the Necessary

OK, I admit, some comment tags are absolutely necessary. But, full sentences within the comment tags are not necessary. A comment such as <!– headline starts here –> can easily be reduced to <!–headline–>. And all whitespace within and around the tags should be eliminated.

If your comment tags are built into your content management system templates and are no longer necessary once the content has been added, you can use a script to eliminate the tags before the page is posted.

Store Comments Off-Line

In a template-based system, you might want to create two versions of your template, one with no comments that is used for publishing and one that is heavily commented and stored off-line and can be referred to for maintenance. The same can be done for your CSS and Javascripts.

By following these easy hints, you can optimize your page download while still making future maintenance seamless.

You might also be interested in:

2 Responses to “Well Commented Code Slows Your Page Load”

  1. Christine Says:

    Thanks for that input. I have tons of comment tags in my pages. Looks like I need to do some clean up.

  2. YahooBot Says:

    Nice site, thanks for information!

Leave a Reply