On Aug 19, 12:00 pm, Jon Brisbin <[EMAIL PROTECTED]> wrote:
> I also do UA sniffing. So does GWT.
I guess your point here is that browser sniffing is OK because GWT
does it.
[...]
> But I don't like feature detection because a) when people tell you you
> should do things "just because",
The logic here is completely at odds with your statement above.
> and b)
> you can't do things like serve content that is tailored to their
> browser.
The point of the web is that you don't care what browser visitors are
using. You provide content that meets published standards and leave
it up to user agents to support the same standards. There are various
strategies to accommodate UAs that either don't fully implement
standards or have bugs in their implementations.
> Performance-wise, I simply can't swallow that dropping a bunch of
> if(browser.featureExists){} logic branches is more efficient, either
> for the developer or the JavaScript engine, than a regex match on the
> UA string that serves browser-specific code.
The particular method used should not be relevant to performance -
testing need only be done once, mostly before the header has finished
being processed. There is no need to fork code every time it is
called.
[...]
> Writing reusable
> regexs that withstand software updates is much easier than keeping up
> with features that may or may not be available.
How do you keep up with the 2,400 UA strings listed at user-
agents.org, or perhaps use www.tnl.net which lists over 78,000
browsers. It doesn't seem simple to me.
> It's been my
> experience that feature detection has unintended consequences if you
> pick the wrong feature.
Picking the wrong browser string has no consequences?
> It also doesn't tell you *how well* that
> feature is implemented.
The UA string doesn't tell you anything about any feature, you only
guess about support that you think might be correct. Given that there
are vastly more UA strings that features that need to be tested for, I
think the odds are stacked against you.
> Best not to guess. You'll be disappointed.
UA sniffing is about guessing features based on an unspecified string
of which there are more than 78,000 different versions. Feature
detection is about knowing a specific feature works because you've
tested for it.
> Consider UA sniffing because a) it works brilliantly in both server
> and client and you get the same results;
Hey, do this because I said so. Remember 'But I don't like feature
detection because a) when people tell you you should do things "just
because"',
> b) server-side browser
> detection should involve using *all* the information you have in
> there.
How many UA strings to you support? All 78,000? And every bit of
every string? It seems to me that those who like UA sniffing support
a very small sub-set of browsers and at most 2 versions - they will be
challenged when they're required to differentiate between IE 5.5, 6, 7
and 8, and that's a very small sub-set of the 481 browser "families"
noted at user-agent-string.info.
Even the libraries like jQuery and Prototype.js that use UA sniffing
only use it where they consider it too difficult to do a feature test
(or were too lazy to write one).
> They went to a lot of trouble to be real specific, I don't know
> why we can't use that information. I get the impression that a lot of
> people aren't successful with UA sniffing because they don't spend
> enough time getting it right and then don't understand why it doesn't
> work like they expect
Quite the contrary. Those who eschew UA sniffing know that feature
detection it is more reliable and creates far fewer maintenance
headaches. Consider my ISP who sniffs for Safari and serves a
crippled page because it hasn't updated its script since version 1.0.
If I change my UA string to mimic Firefox 2 all is sweet. Had the ISP
used feature detection instead, they'd not have to change anything and
I'd not have to spoof Fx.
As it is, they have to update their sniffing for versions 2 and 3 (at
least).
> If a feature-detection "configure" script could be sent down on the
> first access and all the important dependent functionality was tested
> for then, that would be a greater help even than UI sniffing.
That is pretty much how feature detection works, except that you don't
need to trust a UA string that doesn't even have a public
specification for what should be in it.
--
Rob
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"iPhoneWebDev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/iphonewebdev?hl=en
-~----------~----~----~----~------~----~------~--~---