I’ve recently seen some information about avoiding coding to specific browsers an instead using feature/bug detection. It seems that John Resig, the creator of jQuery is a big fan of feature/bug detection (he has an excellent talk that includes a discussion of this on YUI Theater). I’m curious if people are finding that this approach makes sense in practice? What if the bug no longer exists in the current version of the browser (It’s an IE6 problem but not 7 or 8)?
I’ve recently seen some information about avoiding coding to specific browsers an instead using
Share
Object detection’s greatest strength is that you only use the objects and features that are available to you by the client’s browser. In other words given the following code:
allows you to cleanly separate out the browsers without naming names. The reason this is cool is because as long as a browser supports
getFooyou don’t have to worry which one it is. This means that you may actually support browsers you have never heard of. If you target user agent strings find the browser then you only can support the browsers you know.Also if a browser that previously did not support
getFoogets with the program and releases a new version that does, you don’t have to change your code at all to allow the new browser to take advantage of the better code.