Parcourir la source

added support of lazy loaded images

Gildas il y a 7 ans
Parent
commit
e61caa45d9
1 fichiers modifiés avec 3 ajouts et 0 suppressions
  1. 3 0
      node-puppeteer/single-file-puppeteer.js

+ 3 - 0
node-puppeteer/single-file-puppeteer.js

@@ -66,6 +66,9 @@ exports.getPageData = async options => {
 			await page.setUserAgent(options.userAgent);
 		}
 		await page.setBypassCSP(true);
+		if (options.loadDeferredImages) {
+			SCRIPTS.unshift("../lib/lazy/web/web-lazy-loader-before");
+		}
 		await Promise.all(SCRIPTS.map(scriptPath => page.evaluateOnNewDocument(fs.readFileSync(require.resolve(scriptPath)).toString())));
 		await page.goto(options.url, {
 			waitUntil: options.puppeteerWaitUntil || "networkidle0"