avif-webp-checker
v1.0.0
Published
The plugin checks whether the AVIF and WebP browser supports and adds the appropriate classes to the tag html
Downloads
337
Maintainers
Readme
avif-webp-checker
The plugin checks whether the AVIF and WebP browser supports and adds the appropriate classes to the tag html.
Install
npm i avif-webp-checker
Import
const isAvifWebp = require("avif-webp-checker");
or
import isAvifWebp from 'avif-webp-checker'
Options
Type: object
mode
Type: string
Default: all
Possible values:
- «avif» — Add only support «AVIF»
- «webp» — Add only support «Webp»
- «all» — Add support «AVIF» and «Webp»
avifClass
Type: string
Default: avif
Class is added if the browser supports the AVIF format
webpClass
Type: string
Default: webp
Class is added if the browser supports the Webp format
onlyClass
Type: boolean
Default: true
In the "all" mode, only 1 of the classes is added.If the browser supports the AVIF format adds AVIF support class, if the browser does not support the AVIF format, but supports Webp format. Webp support class is added.
Usage
const isAvifWebp = require("avif-webp-checker");
isAvifWebp({mode: "webp", webpClass: "mywebpclass"});
or
const isAvifWebp = require("avif-webp-checker");
isAvifWebp();