https://github.com/jokeyrhyme/is-webcomponents-supported
does this JavaScript environment support WebComponents?
https://github.com/jokeyrhyme/is-webcomponents-supported
browser feature-detection javascript webcomponents
Last synced: about 2 months ago
JSON representation
does this JavaScript environment support WebComponents?
- Host: GitHub
- URL: https://github.com/jokeyrhyme/is-webcomponents-supported
- Owner: jokeyrhyme
- License: bsd-2-clause
- Created: 2015-06-16T12:20:49.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2020-05-25T04:08:56.000Z (about 6 years ago)
- Last Synced: 2025-08-15T13:20:44.543Z (10 months ago)
- Topics: browser, feature-detection, javascript, webcomponents
- Language: JavaScript
- Size: 69.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# is-webcomponents-supported.js [](https://www.npmjs.com/package/is-webcomponents-supported) [](https://travis-ci.org/jokeyrhyme/is-webcomponents-supported)
does this JavaScript environment support WebComponents?
## What is this?
I made this after reading [Polymer for the Performance obsessed](https://aerotwist.com/blog/polymer-for-the-performance-obsessed/)
by [Paul Lewis](https://twitter.com/aerotwist), who mentions a "good little
check" devised by [Glen Maddern](https://twitter.com/glenmaddern).
## Supported Environments
I've manually tested in a range of environments:
- `true`: Chrome (43)
- `false`: Node.js (0.12), Firefox (38)
## Usage
- CommonJS (e.g. Node.js, Browserify, etc) use [index.js](index.js)
```javascript
var isWebComponentsSupported = require('is-webcomponents-supported');
console.log(isWebComponentsSupported()); // `true` or `false`
```
- [dist/index.js](dist/index.js) is a UMD-wrapped version for browsers and AMD
```html
console.log(isWebComponentsSupported()); // `true` or `false`
```
## API
### `isWebComponentsSupported(doc)`
- @param {`Document`} [doc] a DOM Document to run tests against
- @returns {`Boolean`} does this JavaScript environment support WebComponents?
This project uses the global `document` object if you do not provide one. If you
are performing other tests against non-global implementations for some reason,
then this allows you to pass in any such object.