Browser information: "User Agent"

Browsers sends us a string called the User Agent designation. A server can use that User Agent string to determine what browser is used to access the site, including the version and different features that it supports or not.

Using the User Agent information, we can define the name of the browser (Internet Explorer, FireFox, SeaMonkey, Chrome, Safari, Opera, various smart phones, etc.) and the version of the browser used. This information can in turn be used to determine which files to send to the browser to make it work better.

For JavaScript and CSS files we can use that information to preprocess the files and send the browser just the data necessary for that version. For example, if a browser version supports a better feature, we send a JavaScript that makes use of it and does not include a fallback for older versions of that browser. So the JavaScript could look like this:

#if IE10
r = new FileReader;
...
#else
alert("FileReader not supported"); // support for FileReader in older versions is extensive
...
#endif

This can be done in CSS files as well. That way we can avoid sending -moz-... options to IE or Chrome, for example.

Details about user agent strings:

 

Snap! Websites
An Open Source CMS System in C++

Contact Us Directly