Page 1 of 1

Why not serverside browser detection?

Posted: Fri Mar 31, 2006 7:42 am
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

Posted: Fri Mar 31, 2006 9:23 am
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.

Re: Why not serverside browser detection?

Posted: Fri Mar 31, 2006 9:54 am
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.

Posted: Tue Apr 04, 2006 2:42 pm
by asgerhallas
Thank you very much. You got me thinking different on this one now :)

/Asger