I don't comment HTML at all. It's so structural that it's pointless. Though Limbo's comments are useful.
Programming, in some cases, I comment the hell out of it in other cases I don't comment at all. If it's something only I'm editing and using, I do only "reminder" comments to myself. However, I've got a small set of JavaScript scripts together for our subsidiary companies that is insanely commented (there's also a production version of each without comments):
Code:
/*
Method: init
============================================================
Summary: Grabs all links withing #main-content which have
an href set and calls check() for each. Does
not execute if DOM methods are absent.
Params: none
------------------------------------------------------------
*/
init: function() {
if (!document.getElementsByTagName || !document.getElementById) return false;
var all = document.getElementById("main-content").getElementsByTagName("a");
for (i = 0; i < all.length; i++) {
if (all[i].href) {
ICxLinks.check(all[i]);
}
}
},
/*
Method: check
============================================================
Summary: Splits up the link and pulls the extension from
the link. If that extension is found in either
of the arrays (openInNewWindow and
openInSameWindow) it applies the appropriate
behavior and appends <span>(s) as necessary.
* If external links should open in a new window,
check if this
Params: <a> object
------------------------------------------------------------
*/
check: function(link) {
// get the extension of the link
var extension = ICxLinks.getExt(link);
// default values for properties of a link
var isExternal = false;
var isNewWindow = false;
// check if the link is external
if (link.href.indexOf(ICxLib.thisDomain) == -1) isExternal = true;
// check if the link doesn't have a child image
if (link.getElementsByTagName("img").length == 0) isImageLink = false;
// if external links open in new windows, this link is external, and not an image link, set it to open in a new window
if (ICxConfig.externalNewWindow && isExternal) isNewWindow = true;
// loop through the new window extensions array
for (j = 0; j < ICxConfig.openInNewWindow.length; j++) {
if (extension == ICxConfig.openInNewWindow[j]) {
isNewWindow = true;
// if the link does not contain any images, append a span with class equal to its extension
if (link.getElementsByTagName("img").length == 0) {
ICxLinks.appendSpan(link, extension);
}
}
}
// loop through the same window extensions array
for (j = 0; j < ICxConfig.openInSameWindow.length; j++) {
if (extension == ICxConfig.openInSameWindow[j]) {
// if the link does not contain any images, append a span with class equal to its extension
if (link.getElementsByTagName("img").length == 0) {
ICxLinks.appendSpan(link, extension);
}
}
}
// by now, if we've determined the link should be opened in a new window, do so
if (isNewWindow) {
ICxLinks.newWindow(link);
}
},
The version with comments: 11KB. The version without: 5KB. It would be even smaller if I had used PACKER, but it caused some cryptic error, so I said forget it.