Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

psi

Package Overview
Dependencies
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

psi

PageSpeed Insights with reporting

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.9K
decreased by-31.4%
Maintainers
2
Weekly downloads
 
Created
Source

psi Build Status

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.

Install

$ npm install --save psi

Usage

var psi = require('psi');

// get the PageSpeed Insights report
psi('html5rocks.com').then(function (data) {
  console.log(data.ruleGroups.SPEED.score);
  console.log(data.pageStats);
});

// output a formatted report to the terminal
psi.output('html5rocks.com').then(function () {
  console.log('done');
});

API

psi(url, [options])

Returns a promise for the response data from Google PageSpeed Insights.

url

Required
Type: string

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

options

Type: object

key

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.

strategy

Type: string
Default: mobile
Values: mobile, desktop

Strategy to use when analyzing the page.

locale

Type: string
Default: en_US

Locale results should be generated in.

threshold

Type: number
Default: 70

Threshold score to pass the PageSpeed test.

psi.output(url, [options])

Output the formatted report to the terminal.

Returns a promise for the response data from Google PageSpeed Insights.

url and options is the same as psi().

CLI

$ npm install --global psi
$ psi --help

  Usage
    psi <url> <options>

  Example
    psi todomvc.com --strategy=mobile

  Options
    --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
    --screenshot   jpg screenshot
    --locale       Locale results should be generated in.
    --threshold    Threshold score to pass the PageSpeed test.
    --optimized    Get the URL of optimized resources.
    --download     Download optimised resources.

Getting PSI into your build

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.

License

Apache-2.0
Copyright 2015 Google Inc

Keywords

FAQs

Package last updated on 10 Nov 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc