Feature detection for host objects
JavaScript CSS
Latest commit 929d863 Oct 30, 2013 @Raynos Merge pull request #3 from mvaled/master
Adds i18n detection
Failed to load latest commit information.
node_modules/read-dir-files builded it Apr 1, 2012
test Fixed tests to be better Apr 1, 2012
LICENCE first commit Jan 27, 2012
README.md Fixed a few grammar mistakes. Jan 30, 2012
build.js Fixed tests to be better Mar 31, 2012
feature.js Adds detection of argument support in Number.toLocaleString. Oct 30, 2013



Detecting those host environment features for you. See what your browser supports


<script src="cdn/../feature.js"></script>
    if ([
    ].every(function (v) { return window.features[v] })) {
        console.log("your browser has modern DOM features!");


  • Dynamic APIs
  • Only polyfilling the missing features
  • Quickly check what host features your browser has



window.features is a global object containing all the features that are present in this browser. If the feature is present its value is true and false if the feature test failed.

if (features["DOM.EventTarget.addEventListener"]) {
    window.addEventListener("click", handler);
} else {
    window.attachEvent("onclick", handler);

The tests file shows the list of features currently being detected. It's encouraged that rather then use the entire file, you build your own file using only the features you want.

Currently the easiest way to make a custom build is to

  • clone this project
  • delete any files from lib/features you don't want
  • run node build.js
  • take your fresh feature.js file and use it

Dynamic APIS

Dynamic APIs require you to feature detect any part of the host environment you want to use. This is an extension of the progressive enhancement technique.

The basic idea is that you have a HTML/CSS page that works. Then include a javascript enhancement file which checks whether the host environment has the features it needs. If it has them (either natively or by polyfill) it will safely enhance the page without throwing an error. If the browser doesn't have the features then rather then throwing a run-time error it will just do nothing.


Just include <script src="feature.js"></script>


See test/test.html


  • Raynos

MIT Licenced