• Stars
    star
    462
  • Rank 94,832 (Top 2 %)
  • Language
    CoffeeScript
  • License
    MIT License
  • Created over 11 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Grunt plugin to run Google PageSpeed Insights as part of CI

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

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:

grunt.loadNpmTasks('grunt-pagespeed');

Or, add this to your project's Gruntfile.coffee gruntfile:

grunt.loadNpmTasks 'grunt-pagespeed'

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

require('load-grunt-tasks')(grunt);

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: "https://developers.google.com"
  },
  prod: {
    options: {
      url: "https://developers.google.com/speed/docs/insights/v1/getting_started",
      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
    }
  }
}

Options

nokey

Type: Boolean

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

key

Type: String

Google API Key

url

Type: String

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

Target Properties

url

Type: String

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

locale

Type: String

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

strategy

Type: String

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

threshold

Type: Number

Threshold score that is needed to pass the pagespeed test

paths

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

License

MIT ยฉ James Cryer

More Repositories

1

generator-mean

Yeoman generator for a MEAN stack, inspired by mean.io
JavaScript
120
star
2

grunt-pagespeed-ngrok-sample

Sample project for grunt-pagespeed and ngrok
JavaScript
49
star
3

jquery-bookmarklet-boilerplate

A boilerplate for developing jQuery based bookmarklets
JavaScript
19
star
4

grunt-har-gen

Grunt plugin for generating HAR files from a series of local URLs
JavaScript
9
star
5

phpunit-watchr

Simple node app to watch a directory and run phpunit tests
JavaScript
8
star
6

generator-finatra

Scala
6
star
7

node.js-youtube-scraper

jQuery Mobile App which scraps content from YouTube homepage
4
star
8

jquery.postcodeanywhere

jQuery plugin to lookup Postcodes via the Postcode Anywhere service
JavaScript
4
star
9

grunt-phpspec

Grunt plugin to run phpspec
CoffeeScript
4
star
10

addthis-analytics

Small library for utilising the AddThis.com Analytics API
3
star
11

grunt-rcukes

gruntjs plugin to run ruby cucumber via grunt
CoffeeScript
3
star
12

xen-display

Display a list of virtual machines with each status
Ruby
3
star
13

flickr-for-wordpress

Pull latest photos from Flickr Photostream for specified user
2
star
14

generator-pattern-primer

JavaScript
2
star
15

jquery.ajax-file-uploader

jQuery plugin for uploading files via AJAX
JavaScript
2
star
16

addthis-analytics-wp

Wordpress plugin using the addthis-analytics lib
PHP
2
star
17

songbird-sinatra

URL Shortner App using Ruby, Sinatra and MongoDb (originally Redis)
Ruby
2
star
18

geddy-todo

Vanilla Geddy.js Todo App
JavaScript
2
star
19

coredatapref

Experimental project exploring Core Data performance
Objective-C
1
star
20

Notez

Experimental project exploring multiple CoreData sources and encryption
Objective-C
1
star
21

progruntjs

1
star
22

lithium-geo

PHP
1
star
23

TweetieTap

Experimental app using @anywhere Twitter JS library
JavaScript
1
star
24

mobi-rss

Sinatra App for Viewing RSS feeds from YQL
1
star
25

knockout-sample

JavaScript
1
star
26

opencv-example

Prototype app for using AWS Lambda and OpenCV to detect the number of faces in images.
JavaScript
1
star
27

drawit

Demo repo for drawing on iPhone / iPad
Objective-C
1
star
28

newshack

JavaScript
1
star
29

shapez

Experimental project exploring Core Data and Touch / Shake events
Objective-C
1
star
30

postez-for-wordpress

A flexible widget to allow the user to select one or many custom post types to display as a sidebar widget
PHP
1
star
31

jrcryer.github.com

CSS
1
star
32

wp-image-advert

Advertise a post with a media file as a widget on WordPress
PHP
1
star
33

amplify-sample

Sample amplify.js app
JavaScript
1
star
34

story-newshack

JavaScript
1
star
35

twitter-for-wordpress

Basic Twitter Plugin to pull tweets from specified account
PHP
1
star
36

google-site-map-for-wordpress

Generates Google Site Map for Wordpress. Sitemap is automatically generated to the root of the Wordpress install. The sitemap is re-generated on content publishing.
PHP
1
star