|
|
Feature Detection: State of the Art Browser Scripting
|
05/01/2009, by Peter Michaux
|
The goal of feature detection in browser scripting with JavaScript is straight forward. Before our code uses an object or object reference we want to know that our use of it will execute without error and behavior as we are expecting. If we don't know these things before we use the object or object reference then we don't want to use it because using it would risk a broken page and ultimately an unsatisfactory user experience.
The idea of feature detection has been around for many years. If you are writing a script for the general web, where anyone with a web browser can visit your page then you will likely need to spend a decent amount of time thinking about how the feature detection works and only add progressive enhancements to your page when you know those enhancements will work. Good feature detection is one of the fundamental indicators of a quality browser script...but developers still aren't using it! Look in all the mainstream JavaScript libraries. They sniff navigator.userAgent even when far better tests are well known.
This article compiles all of the various feature detection techniques I have thought about, encountered and learned from others. There are many. The ideas are not that complex. Sometimes determining the way to make the right test is complex but the ideas about testing procedures are not.
Read More...
|
Rate this Ajax News
Rating: 2.0 out of 1 vote cast
| |
|
|
| |
|
|
|
|
|
|
|
|