Why not serverside browser detection?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
asgerhallas
Forum Commoner
Posts: 80
Joined: Tue Mar 14, 2006 11:11 am
Location: Århus, Denmark

Why not serverside browser detection?

Post by asgerhallas »

Hi,

How come it's not common (as far as I'm concerned) to make a server-side browser detection script decide which CSS-file to include in cross-browser designs?
As I can see, it would be much cleaner than all the CSS-hacks that's beeing used, or am I mistaken?

Is there a point I'm missing?

/asger
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

  • Maintaining compatibility with the CSS being generated by code can be difficult.
  • If you choose separate files, then you have that many files to maintain just for a single view.
The hacks are often less obtrusive than either of those.
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Re: Why not serverside browser detection?

Post by Roja »

asgerhallas wrote:Hi,

How come it's not common (as far as I'm concerned) to make a server-side browser detection script decide which CSS-file to include in cross-browser designs?
As I can see, it would be much cleaner than all the CSS-hacks that's beeing used, or am I mistaken?

Is there a point I'm missing?

/asger
Lets split the issue into the "Theory", and the "Reality".

In Theory:

- Working around a browser is non-ideal, so don't do that.
- You can make wonderful cross-browser designs without any hacks
- You should only need "a few" hacks, so conditional comments should be good enough

In Reality:

- You have to work around the largest marketshare browser the most, so you have to do SOMETHING.
- Some nice designs require hacks.
- Some nice designs require LOTS of hacks.

So, you end up with what we have - a general rule that you should do conditional comments, and minor exceptions to the rule where you do server-side to provide different css to different browsers.

Theres a bunch of reasons not to do server-siding:

- It encourages bad behavior. If you will use non-standard content ("Hacks") for IE, why should they change?
- It lies to search engines, giving them different information than you would give a user
- It adds more work to the webserver to serve what might be static content
- It adds more work for the developers, who have to maintain multiple css files instead of one
- It increases the number of http requests on a page, reducing the speed of that page
- Server-side browser detection is unreliable, and often flat out wrong (And users can lie easily)

All of which are "minor" in the right situation, so they can be ignored - in the right situation. The general rule, however, is to go with conditional comments.
asgerhallas
Forum Commoner
Posts: 80
Joined: Tue Mar 14, 2006 11:11 am
Location: Århus, Denmark

Post by asgerhallas »

Thank you very much. You got me thinking different on this one now :)

/Asger
Post Reply