Grunt plugin to run Google PageSpeed Insights as part of CI
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

grunt-pagespeed Build Status devDependency Status Dependency Status

Grunt plugin for running Google PageSpeed Insights

Run mobile and desktop performance tests for your deployed site using Google PageSpeed Insights, uses psi and gpagespeed.

This plugin is developed for Grunt 0.4.1 and is not tested for backward compatibility with Grunt 0.3.x.


Install this grunt plugin with the following command:

npm install grunt-pagespeed --save-dev

Loading the plugin

Add this to your project's Gruntfile.js gruntfile:


Or, add this to your project's gruntfile:

grunt.loadNpmTasks 'grunt-pagespeed'

Alternatively use load-grunt-tasks to load your plugins.


Google API Key

By default we recommend using the nokey option to test-drive PageSpeed Insights. This doesn't require any extra work on your part nor an API key.

For a production-level build process, registering for an API key is recommended from the Google Developer Console in order to use this module.

Pagespeed task

Run this task with the grunt pagespeed command.

This task is a multi task so any targets, files and options should be specified according to the multi task documentation.

###Usage Example

pagespeed: {
  options: {
    nokey: true,
    url: ""
  prod: {
    options: {
      url: "",
      locale: "en_GB",
      strategy: "desktop",
      threshold: 80
  paths: {
    options: {
      paths: ["/speed/docs/insights/v1/getting_started", "/speed/docs/about"],
      locale: "en_GB",
      strategy: "desktop",
      threshold: 80



Type: Boolean

Use the nokey option to test-drive PageSpeed Insights before acquiring a key for production builds.


Type: String

Google API Key


Type: String

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

Target Properties


Type: String

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


Type: String

The locale that results should be generated in. This is mandatory.


Type: String

The strategy to use when analyzing the page. Valid values are desktop and mobile.


Type: Number

Threshold score that is needed to pass the pagespeed test


Type: Array

An array of URL paths that are appended to the URL

Sample output

The grunt task outputs the results as follows if everything passes:

Passing task

If the task fails to pass the threshold, then it ouputs something similar to the image below:

Failing task


MIT © James Cryer