From time to time the idea is put forth that Opera (and Firefox, for that matter) needs to start dealing with bad code. There are two problems with that view:

  1. Opera already deals with quite a bit of “bad code” (but there’s always room for improvement)
  2. Just dealing with bad code isn’t enough: you have to deal with it the same way someone else does.

#2 is the tough part.

The rules for dealing with good code are, for the most part, specific. If you encounter well-formed HTML, you can be reasonably sure you know what the author meant. But there are very few rules for dealing with bad code. Trying to "deal with it" means trying to guess what the author meant, and sometimes different assumptions are equally as likely.

Example:


<p><b>Here's some text</i> and here's some more.</p>

Did the author close the non-existent italics by mistake, meaning to close the bold? Or did he open bold by mistake, intending to open italics? Or is the closing italics tag left over from copy-and-paste? Depending on what assumptions the browser makes, it should display it as:

Here’s some text and here’s some more.

Here’s some text and here’s some more.

Here’s some text and here’s some more.

And that’s just a simple example. It gets wilder when you throw in issues like inline vs. block elements. A paragraph should never appear inside a tag for text formatting, like bold or italic. By all rights, starting a new paragraph (or more precisely, ending the previous one) should also revert to plain formatting. But a lot of old pages expect the formatting to continue into the next paragraph, because way back when, a P tag was a double-line break, not a container.

Now, suppose that Browser A always makes the first assumption, and Browser B always makes the second. If someone tests their code in Browser A, and it happens to be what they want it to do, they won’t necessarily notice that their code is broken. The result: the site looks wrong in Browser B, and the page author — who thinks the page is fine, since he tested it in Browser A — blames Browser B.

Multiply that scenario by millions of pages and you have a large chunk of the web as we know it today.

So the solution isn’t just to “handle bad code.” It’s to handle that bad code in the same way that the dominant browser handles it. And since there’s no document you can look to for guidance, that means taking every possible chunk of bad code, running it through the other browser, and seeing what it does to it.

And there are a lot of ways to break code!

Even Microsoft did this back when IE was new. At the time, lots of people were writing broken code and testing it by seeing whether it looked right in Netscape. So IE had to make the same assumptions Netscape did on certain things. Once IE became established, they diverged.

Some relevant articles:

This post originally appeared on Confessions of a Web Developer, my blog at the My Opera community.

Opera BrowserIn an interview at Opera Watch last week, Opera CEO Jon von Tetzchner responded to the eternal question: with less than 1% of global marketshare, why should web developers make the effort to support Opera? His response demonstrates another perspective on the numbers:

I believe we have something like 10 – 15 million active desktop users. That is actually quite a lot of people.

If you try to think about it, the place that I’m come from is Iceland. I was born in Iceland, that’s three hundred thousand people – we have a lot more. The place I live is Norway – we have a lot more. Actually if you look at it, the US has about 300 million people that live here, 50 states, about 6 million in each state on average. So which states have people that you would like to ignore?

He goes on to add that Opera Mobile is installed on 40 million mobile phones, with an additional 7 million people actually using Opera Mini. And then there are devices like the Nintendo DS and Wii…

Going by 2005 numbers, only four states have 15 million people or more: California (36M), Texas (23M), New York (19M), and Florida (18M). So take the 10–15M desktop users, the 7M Opera Mini users, and even 10% of the 40M mobile install base, and you’re looking at 21–26 million—the equivalent of the population of Texas.

Put that way, it doesn’t seem so small.

If you’re already supporting Firefox, in most cases the changes to support Opera 9 are minimal. The recently-launched Opera Developer Community has has tools, articles, and other resources to help build cross-platform sites.

Unless, of course, you don’t mind writing off a potential audience the size of Texas.

Well, Firefox 2 beta 1 is out, and I’ve been trying it out. I used to run nightly builds back in the early days, but since 1.0 hit, I haven’t been willing to go below beta-level for my primary browser, so I haven’t really been following development of Firefox 2. (Let me just say I really like in-line spell checking!)

As a web developer, one of the new features that caught my eye is microsummaries. If the name weren’t already taken, “live bookmarks” would have been the perfect description.

Basically it retrieves info from the bookmarked page and updates the label on your bookmark. Examples given include the current price and remaining time for an auction, or current stock price, or weather data. The page author can describe what chunk of data to use, or you can write an installable “generator” that applies itself to some list of pages.

This is a pretty cool idea: basically a 1-item RSS feed, automatically generated from the current page. (The disadvantage is that the browser retrieves the full page and then extracts the data, whereas an RSS feed is already summarized.) Edit: Apparently it’s also possible to link to a 1-line text document instead.

So, being handed a new tool, I immediately started trying to come up with something to do with it.

And came up more-or-less empty.

There are only two areas on my site that I update regularly: Flash: Those Who Ride the Lightning and this blog—and both are more suited to the list of recent updates that you get with RSS or Atom than the latest-info-only that you get with a microsummary.

It might prove useful for server monitoring, though. Condense the important info from a report (like “No alerts” vs “Server X down!”) and put it on the browser toolbar.

Opera BrowserOperaWatch reports that this week’s development build of Opera passes the Acid2 test. This makes Opera the first browser for Windows to pass! Previous browsers included Safari (Mac only), iCab (Mac only), and Konqueror (Linux/Unix). I’m sure you could get Konqueror to run on Windows under Cygwin, but it seems like a lot of effort just to run a web browser.

Opera cautioned that upcoming development builds could regress, but we can expect the final version of Opera 9 to pass the test.

Neither Internet Explorer 7 nor Firefox 2 will make any attempt to pass Acid2, but Mozilla is working on Acid2 fixes in the next version of their rendering engine, Gecko 1.9, which will likely appear in Firefox 3.

The Opera web browser has introduced a Dashboard-like Widget feature in Opera 9 Preview 2*. I believe this is the first 3+ platform widget framework out there.

Dashboard is, of course, Mac OS X only. Yahoo! Widgets (formerly Konfabulator) is Windows XP and Mac OS X only. The KDE Desktop (mostly used on Linux and *BSD) has plans to include floating applets in KDE4’s revamped desktop, Plasma. Opera runs on Windows, Mac, Linux, and a number of other platforms.

Opera’s taken a very similar approach to Apple’s. A widget is a bundle of HTML, CSS, and JavaScript. The most obvious difference is the structure of the bundle: Continue reading