From 5f178b39b2385b72cf0d97ad086ae24f56ad96b0 Mon Sep 17 00:00:00 2001 From: bv-sumit Date: Tue, 10 May 2022 15:07:58 +0530 Subject: [PATCH 1/2] Fix #344 adding page goto options for puppeteer --- src/core.js | 5 ++++- src/index.js | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core.js b/src/core.js index df8a068c..fe9669db 100644 --- a/src/core.js +++ b/src/core.js @@ -24,13 +24,14 @@ function blockinterceptedRequests (interceptedRequest) { function loadPage ( page, url, + pageGotoOptions, timeout, pageLoadSkipTimeout, allowedResponseCode ) { debuglog('page load start') let waitingForPageLoad = true - let loadPagePromise = page.goto(url) + let loadPagePromise = page.goto(url, pageGotoOptions) if (pageLoadSkipTimeout) { loadPagePromise = Promise.race([ loadPagePromise, @@ -267,6 +268,7 @@ async function grabPageScreenshot ({ async function pruneNonCriticalCssLauncher ({ pagePromise, url, + pageGotoOptions, cssString, width, height, @@ -398,6 +400,7 @@ async function pruneNonCriticalCssLauncher ({ const loadPagePromise = loadPage( page, url, + pageGotoOptions, timeout, pageLoadSkipTimeout, allowedResponseCode diff --git a/src/index.js b/src/index.js index e943cd41..c6279624 100644 --- a/src/index.js +++ b/src/index.js @@ -96,6 +96,7 @@ const generateCriticalCssWrapped = async function generateCriticalCssWrapped ( formattedCss = await generateCriticalCss({ pagePromise, url: options.url, + pageGotoOptions: (options.puppeteer && options.puppeteer.pageGotoOptions) || {}, cssString: options.cssString, width, height, From 3a7029a646d1e5cf20200f98f667611f6198a73b Mon Sep 17 00:00:00 2001 From: bv-sumit Date: Tue, 17 May 2022 11:28:40 +0530 Subject: [PATCH 2/2] Fix #344 updating the example --- examples/custom-browser.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/custom-browser.js b/examples/custom-browser.js index bd9a7a9b..ea1e804b 100644 --- a/examples/custom-browser.js +++ b/examples/custom-browser.js @@ -16,10 +16,12 @@ const browserPromise = puppeteer.launch({ } }) penthouse({ + // pageGotoOptions are the options for puppeteer: Check the available options : https://github.com/puppeteer/puppeteer/blob/v14.0.0/docs/api.md#pagegotourl-options url: 'https://google.com', cssString: 'body { color: red }', puppeteer: { - getBrowser: () => browserPromise + getBrowser: () => browserPromise, + pageGotoOptions: {waitUntil: 'networkidle0'} } }) .then(criticalCss => {