Perfection Kills

by kangax

Exploring Javascript by example

← back 223 words

Feature detection all the way

I have been working on a little personal project of mine for the past couple of months. It’s called CFT and stands for Common Feature Tests. There’s nothing really ground-breaking about it; CFT is simply a set of so-called feature tests for Javascript (or rather for any ECMAScript-compliant flavor – be it Microsoft’s JScript, Mozilla’s JavaScript or WebKit’s JavaScriptCore engines).

These tests aim to detect all kinds of quirks that modern (and not so modern) browsers exhibit and detect those quirks in the most straight-forward way – using feature detection rather than browser sniffing. There are quite few excellent resources out there on a subject of “browser sniffing vs. feature detection”. It’s definitely worth checking them out.

CFT started as an initiative to replace as many unnecessary browser sniffing from Prototype.js as possible (now that I’m part of the core, I feel bound to do something useful for the library :)). The suite was then extended with other tests that seemed not quite trivial to implement.

I really hope CFT helps developers eliminate browser sniffing code plaguing their scripts. The project is under an MIT license and is hosted on github (although is still in its infancy).

As always, any bugs/suggestions are greatly appreciated.

Did you like this? Donations are welcome

comments powered by Disqus