views:

162

answers:

4

As I use the web, I regularly get runtime errors (usually javascript) being reported via popups. This can make for a really unsatisfying user experience on many otherwise excellent websites and also makes me wonder what functionality I am not getting access to.

Why is this such a common issue? Is this down to a lack of testing or is it browser compatibility issues? What can be done to minimise this kind of issue?

Incidently I don't have the 'Display a notification about every script error' checked.

A: 

It's easy to make mistakes in JavaScript. Until recently with Aptana, there weren't many good tools for coding JavaScript. Not have the benefit of syntax checking or compilation, small typing error can make it into pages. Beyond that, there are time where code that works fine in one browser will cause an error in another. For example, I saw a jQuery plugin that didn't work in IE, but it was fine in every other browser. It turned out to be a variable declared without the 'var' keyword. Firefox and Safari were OK with that, IE wasn't, so it's possible that whoever wrote the code didn't even know it was a problem.

Andrew Van Slaars
+1  A: 

I put it down to a lack of testing.

John Topley
+1  A: 

Its a number of issues.

  1. Many web page creators copy and paste JavaScript code from the web. They are not programmers and may not appreciate the nuances of the language.
  2. Lack of good testing frameworks (At least I don't know any). For Java we have JUNIT and .NET NUNIT etc. Its difficult to automate JavaScript testing at this time.
  3. Poor IDE support. Until recently most IDE's did a poor job supporting JavaScript. Now I see more support but still not the kind that you get for the core languages.
Vincent Ramdhanie
For javascript, EcmaUnit exists and has existed for some time it seems (http://debris.demon.nl/). (disclaimer: I don't have any experience with it :)
warpr
A: 

Yes, the problem is usually testing. Most serious developers will try to test their webpage in many browsers, but there is really many browsers and versions so you can't really test them all.

I usually test when designing using Opera and Firefox, and my collegue who used a Mac tested it in Safari too; then from time to time boot a Vista box (I'm running linux and IE's for linux just isn't reliable to copy all strange IE behaviour) and test it on IE (usually 7 and 8 beta). I would recommend to any web developer not to design using IE! The websites that have the most errors is obviously "designed for IE" because they barely works in other browsers and pops more errors. If you design using the standards and test using relatively standard compliant browsers like Opera, Firefox and Safari and then add the dreadful hacks for IE preferably using conditional comments (allthough it is nonstandard and proprietary, it's fortunately, and correctly, regarded as commendt by real browsers so you won't break the working code) you have less problems.

Another reason for errors is that one use frameworks wich is designed to work around browser differences and as a side effect, or possibly just because of an bug, pops error messages in some browsers. I certainly haven't got time to fix a framework just to remove a error message, and unless I can work around the problem and it basically works anyway, I must ignore the error messages, possibly file a report and hope it will be fixed in the next version (or even better hope IE suddenly and magically cease to exist :)

Stein G. Strindhaug