Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_.each(dataPages, function (value, key, list) {
console.log('Awaiting psi-report for: ' + url + '/' + key +'.html');
psi.output(url + '/' + key +'.html',{
nokey: 'true', // or use key: ‘YOUR_API_KEY’
strategy: 'desktop',
}).then(() => {
psi.output(url + '/' + key +'.html',{
nokey: 'true', // or use key: ‘YOUR_API_KEY’
strategy: 'mobile',
});
});
});
}
gulp.task('pagespeed', cb => {
// Update the below URL to the public URL of your site
pagespeed('example.com', {
strategy: 'mobile',
// By default we use the PageSpeed Insights free (no API key) tier.
// Use a Google Developer API key if you have one: http://goo.gl/RkN0vE
// key: 'YOUR_API_KEY'
}, cb);
});
gulp.task('desktop', ['mobile'], function (cb) {
// output a formatted report to the terminal
psi.output(site, {
strategy: 'desktop',
locale: 'en_US',
threshold: 80
}, cb);
});
gulp.task('psi:desktop', ['serve:tunnelled'], function() {
var site = browserSync.instance.tunnel.url;
// Ensure http protocol is used to avoid breaking resources.
site = site.replace(/^https?/, 'http');
// Add user-defined path.
site = site + (psiPath || '');
return psi.output(site, {
nokey: 'true',
strategy: 'desktop',
threshold: 1 // Prevents error if score is below default of 70.
});
});
gulp.task('pagespeed', 'Run PageSpeed Insights', (cb) =>{
// Update the below URL to the public URL of your site
pagespeed.output(packageJSON.homepage, {
strategy: 'mobile' // desktop
// Use the PageSpeed Insights free (no API key) tier.
// Use a Google Developer API key if you have one: http://goo.gl/RkN0vE
// key: 'API_KEY'
}, cb);
});
gulp.task('pagespeed', function (cb) {
// Update the below URL to the public URL of your site
pagespeed.output('example.com', {
strategy: 'mobile',
// By default we use the PageSpeed Insights free (no API key) tier.
// Use a Google Developer API key if you have one: http://goo.gl/RkN0vE
// key: 'YOUR_API_KEY'
}, cb);
});
gulp.task('psi:mobile', ['serve:tunnelled'], function() {
var site = browserSync.instance.tunnel.url;
// Ensure http protocol is used to avoid breaking resources.
site = site.replace(/^https?/, 'http');
// Add user-defined path.
site = site + (psiPath || '');
return psi.output(site, {
nokey: 'true',
strategy: 'mobile',
threshold: 1 // Prevents error if score is below default of 70.
});
});
gulp.task('pagespeed', cb =>
// Update the below URL to the public URL of your site
pagespeed(
'https://www.dancedeets.com/new_homepage',
{
strategy: 'mobile',
// By default we use the PageSpeed Insights free (no API key) tier.
// Use a Google Developer API key if you have one: http://goo.gl/RkN0vE
// key: 'YOUR_API_KEY'
},
cb
)
);
function runPsi(url) {
log('\nStarting PageSpeed Insights');
psi.output(url).then(function (err) {
process.exit(0);
});
}