Global

Members

(constant) AUTHOR :string

Type:
  • string

(constant) LICENSE :string

Type:
  • string

(constant) VERSION :string

Type:
  • string

(constant) screen :object

Holds information about the physical screen the webpage is rendered on.

Type:
  • object

Methods

getCompatInfo(name) → {CompatibilitySpecifier}

Get details on the compatibility of various JavaScript built-ins.

Description:
  • Although this library does provide a polyfill for requestAnimationFrame, getCompatInfo will not show it. The reason for this is that the polyfill does not adapt to the screen's refresh rate.

Examples
// requestAnimationFrame is available
const { supported, name } = viewstat.getCompatInfo("requestAnimationFrame");
console.log( supported ) // true
console.log( name ) // "requestAnimationFrame"
// requestAnimationFrame is available with a prefix
const { supported, name } = viewstat.getCompatInfo("requestAnimationFrame");
console.log( supported ) // true
console.log( name ) // "webkitRequestAnimationFrame"
// matchMedia is available as a polyfill
const { supported, name } = viewstat.getCompatInfo("matchMedia");
console.log( supported ) // true
console.log( name ) // "viewstat.polyfills.matchMedia"
// matchMedia is not available because media queries are not supported at all
const { supported, name } = viewstat.getCompatInfo("matchMedia");
console.log( supported ) // false
console.log( name ) // ""
Parameters:
Name Type Description
name string

The name of the built-in without prefixes or polyfills.

Returns:
Type
CompatibilitySpecifier

init()

Tries to initialize the library.

Description:
  • Tries to initialize the library. Will be done automatically in a browser environment. This can be useful if you're processing JavaScript on the server side.

isInitialized() → {boolean}

Returns true if the library has been initialized and is ready to use.

Description:
  • Returns true if the library has been initialized and is ready to use.

Returns:
Type
boolean

setSilent(bool)

Enable/disable console messages. Messages are enabled by default.

Parameters:
Name Type Description
bool boolean