Share your views on unobtrusive javascript

R

Richard Cornford

d said:
OK, I give up.

At least I'm in good company though.

You are not alone, certainly. Whether the quality of your company is
good or otherwise is another matter.
I'm sure you'll agree that Google,

Google? You mean that gang of inept, halfwit jellies that are
responsible for turning google groups from a reliable and fast,
searchable archive into a flaky, error-spitting, slow, inconvenient and
troublesome epitome of scripting bad-practice and questionable design?
The people who cannot even count the number of posts someone has made to
a group and come up the same total twice in succession, and produce
totals that differ by more than +/-50%? (If they cannot program counting
on computers what could they ever be expected to get right?)

I have not had much to do with Yahoo, but when, in relation to a
question asked on this group, I looked at their YUI code the very first
function I looked at had a gapping hole in its logic. That is not even
the more questionable (and style influenced) areas of host object model
interaction, but the actual logic of the code.

Microsoft employs web developers who write IE only code and still come
up with stuff that errors-out (the infamous "parentElement.prentElement
is null or not an object error" that graces nearly every visit to MSDN,
for example), even when using IE in its default configuration. That is,
people who aspire to no more than the easiest browser-scripting task
(scripting the default configuration of a single browser) and still
cannot get it right.

I have zero experience of AOL.
are some of the largest tech companies in the world

Yes they are.
and attract some of the finest developer minds to work
for them.

Do they? On what basis do you make that assertion? And even if they do,
do they then employ those individuals to design/write the code that
makes up their public faces?
Are they all deluded too?

Take Google, and GMail this time. When GMail was created Opera browser
did not support XML HTTP requests, and GMail used browser sniffing to
tell Opera users that they should find another browser. Opera reacted to
the resulting complaints of their customers by implementing XML HTTP
requests that were (at minimum) compatible with GMail. But it took
someone at Google to go into their code an update the browser sniffing
before Opera could be used with GMail.

Doing that cost Google money. Maybe not much money (particularly as they
don't seem to do much QA testing on their products) but it was more than
no money at all. While the feature detecting approach to XML HTTP
requests (of which plenty of examples considerably pre-date GMail) would
have just worked when presented with a more capable version of Opera.

The people who designed/wrote the original browser sniffing thought they
were doing the right thing, and the people who employed them to do it
thought they were employing the right people to do it. But a bad,
formally baseless, predictably unreliable and technically superseded
design decision had the usual consequences of needlessly costing money
to correct, and then more money to correct the correction when Safari,
Konqueror, IceBrowser, etc, also introduced support for XML HTTP
requests. There is delusion somewhere in an organisation that allows
this to happen, and then allows it to happen again and again.
They're also foolishly sniffing for browsers via the useragent, even
though it's impossible to accurately
determine the browser, and it's pointless trying to do so.

And they are (literally) paying for that mistake.
Douglas Crockford, please explain

In my experience of working in IT I have never worked for an
organisation that did not include confidentiality clauses in its
employment contracts. Usually along the lines of: 'you will say nothing
specifies about what you do here now and for at least 5 years after you
leave our employment'. Now that might be a peculiarly British thing, or
it may relate to the types of industries I have worked in (financial
services being particularly keen on confidentiality), but I don't think
so.

Asking Douglas what he does at Yahoo is probably utterly pointless as he
is likely obliged not to answer.
why the YUI library is sniffing for browsers.

They do it because they don't have the skills/experience not to do it,
and because of that they have taken the attitude that they only support
a small set of 'acceptable' browsers/browser configurations.

There is a misconception about the YUI libraries, that they are some
sort of contribution to the public good. They are not; they are the
tools that Yahoo needs to do the job it perceives it needs to do. They
are publicly available and usable as an exercise in cheep but extensive
QA testing. It is a very clever move, but not altruistic in any way.
Richard says it can't be done, and doesn't need to be.

I said the results of browser sniffing could not accurately identify web
browser or their versions. That is just the logic of the situation; you
cannot distinguish between the character sequence "I am web browser x"
and the character sequence "I am web browser x" by looking at the
characters and their sequence. And there is no requirement that the
character sequence that you are looking at be anything in particular or
even consistent over time. The logic of the situation is undeniable, and
all the 'justifications' that remain for doing it anyway are just a
smokescreen, where the smoke gets in the eyes of the people trying to
make the justification more than those they are trying to justify it to.
I believe you Richard, that the code you write can be
done without sniffing for browsers. I've written lots
of things that didn't need it.

And if you try you will find you could write considerably more.
In my world though (and clearly in the world occupied
by the code from Google, Yahoo, MSN and AOL) there is
a need for it,

Of what relevance is a perceived need when the thing that is needed is
impossible?
and it works on over 99.9% of browsers.

No it doesn't. It is technically baseless and logically faulty in all
browsers, it is just that the actual instances of observed consequences
of those facts is sufficiently low that they are disregarded by many (or
unknown to many).
It's a fact that's proven by the traffic logs from web servers that
99.9% of visiting browsers are
identified to be the main browsers mentioned below.

How does a 'traffic log' identify a web browser? Doesn't it use the User
Agent header? Isn't the User Agent header an arbitrary sequence of
characters that are not specified as having any meaning at all (or even
required to be consistent over time)? Isn't the ability to identify a
web browser from its User Agent header precisely the thing that is the
logical impossibility?

Yes the logs may well identify 99.9% of web browsers as being members of
a limited set of well-known and common web browsers, but if the
'identification' cannot accurately discriminate between web browser
because the techniques they use are formally baseless and logically
flawed then what precisely gets "proven" by them.
Of all the logs I've looked at, you don't even see Opera or Safari in
spoof mode get listed.
People simply aren't doing it.

How could you tell? There is an Epimenidies paradox-like situation here;
if someone is attempting to tell you a convincing lie, and you are
convinced, does the lie then become the truth?
btw, I never heard of NetFront or IceBrowser

No, you spend you time looking at 'traffic logs', where they are listed
as IE 5, 6 or 7 (depending on the version).
and unless they raise their heads above the
level of 0.1% browser market share,

You have no evidence that they are not above 0.1% of the browser market.
Your 'traffic logs', because they will list them as IE versions, can
only suggest to you that their market shares do not exceed whatever
figure you have for IE (assuming the logs in question are representative
of market share, which is very improbable).

But on the subject of small market shares, weren't you whining about a
minor (and rapidly updated) version of Firefox that would crash under
some circumstances, and wanting to take action because of it? Is its
share of the market really greater than your 0.1% apparent cut-off?
I doubt I'll encounter them.

I doubt you would recognise doing so when you do. Both browsers are in
the embedded browser market and feature built into mobile phones,
currently a growth area in web browsing.
If you use an obscure browser, or one with a spoofed useragent, then
what happens to you as you browse the
web is your own fault.

That's right blame the users, when they are doing nothing wrong (HTTP
1,1 allows them to send any User agent Header they like, and not even
send the same one with each request, so whatever they send it _cannot_
be wrong).

There is nothing the commissioner of a new web site wants to here more
than your justification for eliminating (an unknowable proportion of)
their potential customers at the design stage of a project and in a way
that has no relationship to the business they are in. Especially when it
boils down to "it is the user's fault if you cannot take their money off
them".
Most web pages are written for the majority of
browsers and playing with bleeding edge tech,

Bullshit. Most web pages are, and probably will be for a considerable
time to come, ordinary HTML. There are already billions of them.
you can expect less than ideal results.

I expect that people who don't think about what they are doing,
understand the technologies, or care to do the job well, will act to
turn potentially reliable web projects into flaky half-efforts that do
(probably unrecognised) harm to the business and reputations of the
people who commission then.
We're writing javascript that meets the vast majority,
and I don't mean an 80% majority, I mean > 99.9%.

You have already made it clear that you do not understand the factors
that are undermining any clams of yours to be supporting a 'majority' of
any size.
What exactly is wrong with this pseudo code ?

if useragent has opera then browser is opera
else if useragent has safari then browser is safari
else if useragent has flock then browser is flock
else if useragent has firefox then browser is firefox
else if useragent has ie then browser is ie
else if useragent has netscape then browser is netscape
else if useragent has mozilla then browser is mozilla
else browser is unknown and gets a "classic" simple page

The fault with that pseudo code is that the userAgen string is a
reflection of the HTTP User Agent header and the HTTP User Agent header
is specified as being no more any arbitrary sequence of characters and
is not even required to be consistent over time. That is, the code is
predicated upon the premise that the User Agent header is a source of
information, when by specification it is no such thing.

You have also demonstrated the precise reason that we are in a situation
where the HTTP User Agent header cannot be specified as being a source
of information (which clearly was the original, and now long abandoned,
purpose of that header). You are attempting to funnel all of the (many)
browsers that you have never heard of into your '"classic" simple page'.
Now the authors of brand new web browser 'Y' have spend two years
implementing a scriptable dynamic web browser that fully supports
ECMAScript, the W3C DOM(s) (HTML and XHTML), CSS, AJAX and stuffed in a
load of IE compatibility, and now you want to give it a "classic" web
page because you don't recognise its name. And so you make the product
of all their hard work look like 1995's Netscape.

Their solution; they don't tell you its name, they tell you it is IE, or
Mozilla, or Opera, or Safari, or whichever common browser best parallels
the capabilities of the browser they have written.

Of course you are none the wiser because you are looking at 'traffic
logs' and seeing only whichever convincing lie they have chosen to tell
you.
Sniffing for the two most popular spoofers

What criteria can determine the "most popular spoofers"? Might there not
be at least one more popular spoofer that is spoofing so well that you
have not been able to distinguish it form whatever it is spoofing?
gets them identified first, thereby disregarding their spoofery.
Searching for Flock (a variant of Firefox) means it doesn't get seen
as firefox.

If it is a variant of Firefox why not treated it as Firefox? What about
all those over (20-odd) Mozilla/Gecko variants?
Searching for Firefox before netscape means firefox doesn't get
identified as netscape. Then comes IE (which also catches
netscape 8 in IE mode, but that's what we want, because it is running
an IE instance).

And also catches the vast majority of all of those little embedded
browsers that you are blind to.
Then comes netscape, so it doesn't get identified as mozilla.

And there go another crowd of embedded browsers.
Finally a mozilla check last (because so many of the browsers above
also have mozilla
in their useragent).

Do you understand why they all have 'mozilla' in their User Agent
headers? The irony of this whole thing is that it was Microsoft that
introduced spoofing, and did so in order that foolish browser detection
would not result in its new IE browsers getting the "classic" pages back
in the days when Netscape was the big player. And then it was because
browser spoofing was already endemic that in 1998 it was impossible for
the HTTP 1.1 specification to require anything specific of the contents
of the User Agent header.
I know you're going to say that using the useragent
itself isn't a reliable way of trying to determine
the browser.

If I did I would only be repeating a fact that is clear from the HTTP
1.1 specification and evident in the real world.
All I can say (again) is that it works for me (and Google,
and Yahoo, and MSN and AOL)...

And all I can say again is that it doesn't work for you, or Google, or
Yahoo or MSN or AOL. It does not work for anyone, as it is logically
impossible to use an arbitrary sequence of characters do discriminate
between sources of arbitrary sequences of characters. You cannot
accurately identify a web browser from its User Agent header, logically,
there is no formal basis for ever trying, some are known to use User
Agent headers that are (deliberately) indistinguishable from others, and
almost all User Agent headers are user configurable anyway.

Richard.
 
P

Peter Michaux

I have not had much to do with Yahoo, but when, in relation to a
question asked on this group, I looked at their YUI code the very first
function I looked at had a gapping hole in its logic. That is not even
the more questionable (and style influenced) areas of host object model
interaction, but the actual logic of the code.


What particular code in YUI was that? What was the problem?

Thanks,
Peter
 
T

Thomas 'PointedEars' Lahn

David said:
That browser is dead and buried. Anybody still using it will have
problems with virtually every site on the Internet.

That is the official statement I believed too before, but I wouldn't be
so sure about that now. Last time I checked, IE 5 on Mac topped even IE
6 on Windows when it came to standards conforming rendering -- the
layout engine is another one (Tasman, not Trident).

Recently, our company has been "asked" to provide a tableless Plone site
(formatted with CSS) with Mac IE 5 compatibility because some of the
customer's VIPs still use it. It was an about 5-hour-PITA to
restructure the templates (IE 5 Mac does not support @media rules that
Plone uses by default for its stylesheets) but now it looks good and --
more important -- it is still accessible.


Regards,
PointedEars
 
D

David Mark

That is the official statement I believed too before, but I wouldn't be
so sure about that now. Last time I checked, IE 5 on Mac topped even IE
6 on Windows when it came to standards conforming rendering -- the

IE6 has lots of silly rendering problems, as does IE5 for the Mac.
There are lots of published hacks to get around the Mac version's
problems, but none are a good idea, especially since it doesn't do
conditional comments.
layout engine is another one (Tasman, not Trident).

Recently, our company has been "asked" to provide a tableless Plone site
(formatted with CSS) with Mac IE 5 compatibility because some of the
customer's VIPs still use it. It was an

They must be out of their minds.

about 5-hour-PITA to
restructure the templates (IE 5 Mac does not support @media rules that
Plone uses by default for its stylesheets) but now it looks good and --
more important -- it is still accessible.

Certainly you can create styles without hacks that work flawlessly for
IE5 Mac, just as you can for NS4, but it usually isn't worth the
effort. There are a lot of DOM scripting issues with it as well. I
used to test all the way back to IE4 on the Mac, but lately have
decided to forget about both of them. From my experience, I know that
simpler pages will work fine, but complicated applications will have
issues. I do try to avoid things that I know will cause breakdowns.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top