Skip to content

Commit

Permalink
meta tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Apr 8, 2016
1 parent de78eb9 commit a5d1fc7
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 52 deletions.
3 changes: 0 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,3 @@ end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
node_modules
npm-debug.log
16 changes: 0 additions & 16 deletions .jshintrc

This file was deleted.

3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
sudo: false
language: node_js
node_js:
- 'stable'
- '5'
- '4'
- '0.12'
- '0.10'
43 changes: 21 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,29 @@ $ npm install --save psi
## Usage

```js
var psi = require('psi');
const psi = require('psi');

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

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

// Supply options to PSI and get back speed and usability scores
psi('theverge.com', { nokey: 'true', strategy: 'mobile' }).then(function (data) {
psi('theverge.com', {nokey: 'true', strategy: 'mobile'}).then(data => {
console.log('Speed score: ' + data.ruleGroups.SPEED.score);
console.log('Usability score: ' + data.ruleGroups.USABILITY.score);
});
```

As of PSI 2.x, we expose both the PageSpeed Insights speed and usability scores. The latter is based on [usability rules](https://developers.google.com/speed/docs/insights/rules) that score a page based on factors like the presence of a sensible mobile [viewport](https://developers.google.com/speed/docs/insights/ConfigureViewport).


## API

### psi(url, [options])
Expand All @@ -47,7 +48,6 @@ 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.
Expand All @@ -58,29 +58,29 @@ Type: `object`

##### key

Type: `string`
Default: `Free tier`
Type: `string`<br>
Default: Free tier

When using this module for a production-level build process, registering for an API key from the [Google Developer Console](https://developers.google.com/speed/docs/insights/v1/getting_started#auth) is recommended.

##### strategy

Type: `string`
Default: `mobile`
Type: `string`<br>
Default: `mobile`<br>
Values: `mobile`, `desktop`

Strategy to use when analyzing the page.

##### locale

Type: `string`
Type: `string`<br>
Default: `en_US`

Locale results should be generated in.

##### threshold

Type: `number`
Type: `number`<br>
Default: `70`

Threshold score to pass the PageSpeed test. Useful for setting a performance budget.
Expand All @@ -104,19 +104,19 @@ $ npm install --global psi
$ psi --help
Usage
psi <url> <options>
$ psi <url>
Example
psi todomvc.com --strategy=mobile
$ 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
--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.
--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.
--optimized Get the URL of optimized resources.
--download Download optimized resources.
```


Expand All @@ -131,5 +131,4 @@ For testing local project, we recommend using [ngrok](http://www.jamescryer.com/

## License

Apache-2.0
Copyright 2015 Google Inc
Apache-2.0 - Copyright 2015 Google Inc
4 changes: 2 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ var cli = meow([
updateNotifier({pkg: cli.pkg}).notify();

if (!cli.input[0]) {
console.error('Please supply an URL');
console.error('Please specify a URL');
process.exit(1);
}

psi.output(cli.input[0], cli.flags).then(function () {
process.exit(0);
process.exit();
}).catch(function (err) {
if (err.noStack) {
console.error(err.message);
Expand Down
9 changes: 2 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"url": "addyosmani.com"
},
"bin": "cli.js",
"preferGlobal": true,
"engines": {
"node": ">=0.10.0"
},
Expand Down Expand Up @@ -50,13 +49,9 @@
},
"devDependencies": {
"mocha": "^2.3.3",
"xo": "^0.10.1"
"xo": "^0.13.0"
},
"xo": {
"space": true,
"envs": [
"node",
"mocha"
]
"space": true
}
}
1 change: 1 addition & 0 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
/* eslint-env mocha */
var assert = require('assert');
var chalk = require('chalk');
var response = require('./fixtures/response');
Expand Down
1 change: 1 addition & 0 deletions test/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
/* eslint-env mocha */
var assert = require('assert');
var chalk = require('chalk');
var utils = require('../lib/utils');
Expand Down

0 comments on commit a5d1fc7

Please sign in to comment.