PageSpeed Insights with reporting


PageSpeed Insights with reporting

Run mobile and desktop performance tests for your deployed site using Google PageSpeed Insights with tidy reporting for your build process.

$ npm install --save psi
var psi = require('psi');
// get the PageSpeed Insights report 
psi('', function (errdata) {
// output a formatted report to the terminal 
psi.output('', function (err) {

Type: string

URL of the page for which the PageSpeed Insights API should generate results.

Type: object

Type: string
Default: Free tier

When using this module for a production-level build process, registering for an API key from the Google Developer Console is recommended.

Type: string
Default: mobile
Values: mobile, desktop

Strategy to use when analyzing the page.

Type: string
Default: en_US

Locale results should be generated in.

Type: number
Default: 70

Threshold score to pass the PageSpeed test.

Type: function

Type: object

The response from Google PageSpeed Insights.

Output the formatted report to the terminal.

url and options is the same as psi().

Type: function

$ npm install --global psi
$ psi --help
    psi <url> <options>
    psi --strategy=mobile
    --key          Google API Key. By default the free tier is used.
    --strategy     Strategy to use when analyzing the page: mobile|desktop
    --format       Output format: cli|json|tap
    --locale       Locale results should be generated in.
    --threshold    Threshold score to pass the PageSpeed test.

A sample Gulp project using PSI is available.

If you use Grunt, grunt-pagespeed is a task by James Cryer that uses PSI under the hood.

For testing local project, we recommend using ngrok.

Copyright 2015 Google Inc