Bläddra i källkod

resolve frame tree and lazy load images in parallel

Gildas 7 år sedan
förälder
incheckning
ac23db8ece
1 ändrade filer med 6 tillägg och 4 borttagningar
  1. 6 4
      extension/core/content/content.js

+ 6 - 4
extension/core/content/content.js

@@ -83,10 +83,14 @@ this.singlefile.top = this.singlefile.top || (() => {
 	async function processPage(options) {
 		singlefile.ui.init();
 		const processor = new SingleFileClass(options);
+		const preInitializationPromises = [];
 		options.insertSingleFileComment = true;
 		options.insertFaviconLink = true;
 		if (!options.removeFrames && this.frameTree) {
-			options.framesData = await frameTree.getAsync(options);
+			preInitializationPromises.push(frameTree.getAsync(options));
+		}
+		if (options.lazyLoadImages) {
+			preInitializationPromises.push(lazyLoader.process());
 		}
 		options.doc = document;
 		options.win = window;
@@ -107,9 +111,7 @@ this.singlefile.top = this.singlefile.top || (() => {
 				browser.runtime.sendMessage({ processEnd: true, options: { autoSave: false } });
 			}
 		};
-		if (options.lazyLoadImages) {
-			await lazyLoader.process();
-		}
+		[options.framesData] = await Promise.all(preInitializationPromises);
 		await processor.initialize();
 		await processor.preparePageData();
 		const page = await processor.getPageData();