grunt-pagespeed

Grunt plugin to run Google PageSpeed Insights as part of CI

  • 所有者: jrcryer/grunt-pagespeed
  • 平台:
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

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

主要指标

概览
名称与所有者jrcryer/grunt-pagespeed
主编程语言CoffeeScript
编程语言CoffeeScript (语言数: 1)
平台
许可证MIT License
所有者活动
创建于2013-07-20 23:46:28
推送于2022-12-07 02:20:27
最后一次提交2020-10-28 21:47:12
发布数2
最新版本名称v0.4.1 (发布于 2014-12-27 16:46:39)
第一版名称v0.4.0 (发布于 2014-12-27 15:57:17)
用户参与
星数460
关注者数9
派生数16
提交数75
已启用问题?
问题数23
打开的问题数0
拉请求数8
打开的拉请求数11
关闭的拉请求数4
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?