Skip to content

Commit

Permalink
Merge pull request #345 from bv-sumit/sumit_page_goto_options
Browse files Browse the repository at this point in the history
Fix #344 adding page goto options for puppeteer
  • Loading branch information
pocketjoso authored May 17, 2022
2 parents 765f485 + 3a7029a commit 9982d51
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion examples/custom-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
5 changes: 4 additions & 1 deletion src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -267,6 +268,7 @@ async function grabPageScreenshot ({
async function pruneNonCriticalCssLauncher ({
pagePromise,
url,
pageGotoOptions,
cssString,
width,
height,
Expand Down Expand Up @@ -398,6 +400,7 @@ async function pruneNonCriticalCssLauncher ({
const loadPagePromise = loadPage(
page,
url,
pageGotoOptions,
timeout,
pageLoadSkipTimeout,
allowedResponseCode
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 9982d51

Please sign in to comment.