Skip to content
Feature detection for host objects
JavaScript CSS
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib/features fixed details test
node_modules/read-dir-files builded it
test Fixed tests to be better
LICENCE first commit
Makefile Fixed tests to be better Fixed a few grammar mistakes.
build.js Fixed tests to be better
feature.js Adds detection of argument support in Number.toLocaleString.


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

Something went wrong with that request. Please try again.