examples/many-urls.js
function startNewJob () {
  const url = urls.pop() // NOTE: mutates urls array
  if (!url) {
    // no more new jobs to process (might still be jobs currently in process)
    return Promise.resolve()
  }
  return penthouse({
    url,
    ...penthouseOptions
  })
    .then(criticalCss => {
      // do something with your criticalCSS here!
      // Then call to see if there are more jobs to process
      return startNewJob()
    })
}
function startNewJob () {
  const url = urls.pop() // NOTE: mutates urls array
  if (!url) {
    // no more new jobs to process (might still be jobs currently in process)
    return Promise.resolve()
  }
  return penthouse({
    url,
    ...penthouseOptions
  })
    .then(criticalCss => {
      // do something with your criticalCSS here!
      // Then call to see if there are more jobs to process
      return startNewJob()
    })
}
function startNewJob ( ) { const url = urls . pop ( ) // NOTE: mutates urls array if ( ! url ) { // no more new jobs to process (might still be jobs currently in process) return Promise . resolve ( ) } return penthouse ( { url , ... penthouseOptions } ) . then ( criticalCss => { // do something with your criticalCSS here! // Then call to see if there are more jobs to process return startNewJob ( ) } ) }
recursively generates critical css for one url at the time, until all urls have been handled
recursively generates critical css for one url at the time until all urls have been handled