GPSI badge
An NPM package that adds a stylable visual indicator of the loading speed rating of the current page. The raiting is provided by Google PageSpeed Insights API.
How it works
An HTML element with style tag is inserted into the DOM and a fetch call is made to PageSpeed API. Once respone is received the value is updated with corresponding score.
How to use it
Via npm
- install the package with
npm install gpsi-badge
- import
gpsiBadge
and callgpsiBadge.addNew()
inside your code
Via unpkg
-
add badge by calling
gpsiBadge.gpsiBadge.addNew()
-
optionally you can pass configuration object:
{
mountTo: 'footer', // valid argument for querySelectorAll
testHost: 'https://valya.codes' // url to be used while doing tests on localhost
}