Skip to content

Commit

Permalink
readme: update to v5+ API (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
JuanMaRuiz authored and exterkamp committed Nov 7, 2019
1 parent d2c4c06 commit 26645c4
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,24 @@ const psi = require('psi');

(async () => {
// Get the PageSpeed Insights report
const data = await psi('https://theverge.com');
console.log(data.ruleGroups.SPEED.score);
console.log(data.pageStats);
const { data } = await psi('https://theverge.com');
console.log('Speed score:', data.lighthouseResult.categories.performance.score);

// Output a formatted report to the terminal
await psi.output('https://theverge.com');
console.log('Done');

// Supply options to PSI and get back speed and usability scores
// Supply options to PSI and get back speed
const data2 = await psi('https://theverge.com', {
nokey: 'true',
strategy: 'mobile'
strategy: 'desktop'
});
console.log('Speed score:', data.ruleGroups.SPEED.score);
console.log('Usability score:', data.ruleGroups.USABILITY.score);
console.log('Speed score:', data2.data.lighthouseResult.categories.performance.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 Down

0 comments on commit 26645c4

Please sign in to comment.