The recent SiteMeter bug reminds Martin that bad JavaScript code is ruining his Web experience on many sites Last Friday, in case you hadn’t heard, thousands of sites were unavailable to users browsing with Internet Explorer because of a bug in SiteMeter. SiteMeter says of the bug, in hindsight: While researching some anomalies in the data being reported on the new system someone spotted a potential problem where certain browsers may not have been handling the SiteMeter image tag properly and under certain circumstances the browser could potentially create duplicate counts or perhaps not track the visit entirely. In an effort to address the potential problem a change was made in the JS Scripts. Unfortunately this code was accidentally pushed to the live system before it was thoroughly tested. As it turns out it triggered something in Microsoft’s IE 6/7 that caused the browser NOT to load certain pages. From what we’ve determined the problem seemed to occur when a JavaScript Sitemeter tag was not a direct child of the body tag of the document, such as if it were embedded in a table or a div element. The change in code also prevented SiteMeter customers from getting to SiteMeter’s Web site or stats area if they were using IE 6/7 browsers. The Internet was all a-Twitter with this on Friday evening. It reminded me of a constant irritation: bad JavaScript is running rampant on the Web.I often have this in my face, because I enable debugging on my Internet Explorer instances so that I can thoroughly test and debug my own sites. When debugging is enabled, IE responds to a JavaScript error by popping up a dialog box, making noise, and offering to debug. Try putting up with that on every page of a site that has an error in its template. I have the Firebug, YSlow, JSView, and Web Developer add-ons installed in my Firefox instances. When I see a bug in IE, I can either report it using the information in the dialog box (adding one to the line number to compensate for an IE bug), debug it in Visual Studio, or try the same page in Firefox. The Error Console in Firefox (Ctrl+Shift+J) usually displays the same error that IE bleated about, and one or another of the add-ons lets me see the erroneous code easily. I also test my own pages with Opera and Safari; they have error consoles, although buried by default.Recently I have taken the time to report the JavaScript errors I encounter, generally with enough additional information to make it easy to fix, at least when I find them on sites operated by people I know. I realize that this could be more annoying than helpful in some cases, but I guess I’m willing to live with that. At least some of the time my bug report is passed along to the site maintainers and they fix the problem; other times they ignore me or attempt to tell me that my browser settings are wrong.If you all did the same thing, perhaps the Web would be a better place to browse. And if every developer who posted JavaScript publicly did a thorough test of his or her pages using four browsers with full debugging enabled, perhaps we’d never have to see these error messages at all. Software Development