October 2017
Intermediate to advanced
302 pages
7h 27m
English
Now, let's require two more tools at the top of assess.js:
const lighthouse = require('lighthouse');const chromeLauncher = require('lighthouse/chrome-launcher');
chromeLauncher will allow us to open up Chrome to the target page, and then run Lighthouse. Let’s make a function called launchChromeAndRunLighthouse to do exactly this:
function launchChromeAndRunLighthouse(url, flags= {}, config = null) {}
We can optionally pass in some flags and config, which we won't use here (flags can be used to turn on logging as the process unfolds).
Inside the function, we'll launch Chrome, set the port for Lighthouse to run on, and then run it. Lastly, we'll stop Chrome:
function launchChromeAndRunLighthouse(url, ...
Read now
Unlock full access