Created
March 14, 2018 16:43
-
-
Save vikramvi/90f04717baf5bb7f348bb74ab75d8882 to your computer and use it in GitHub Desktop.
lh1.js ( not working - this is as per documentation )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const lighthouse = require('lighthouse'); | |
const chromeLauncher = require('chrome-launcher'); | |
// process.env.args = " --veiw --disable-network-throttling --disable-cpu-throttling" | |
// console.log(process.env.args); | |
function launchChromeAndRunLighthouse(url, opts, config = null) { | |
return chromeLauncher.launch({chromeFlags: opts.chromeFlags}).then(chrome => { | |
opts.port = chrome.port; | |
console.log(lighthouse) | |
return lighthouse(url, opts, config).then(results => { | |
// The gathered artifacts are typically removed as they can be quite large (~50MB+) | |
delete results.artifacts; | |
return chrome.kill().then(() => results) | |
}); | |
}); | |
} | |
const opts = { | |
view: true, | |
disableDeviceEmulation: true, | |
disableCpuThrottling: true, | |
chromeFlags: ['--show-paint-rects'] | |
}; | |
// Usage: | |
launchChromeAndRunLighthouse('https://www.smava.de', opts).then(results => { | |
console.log("HIiiiiiiii"); // Use results! | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment