|
|
@@ -159,10 +159,23 @@ async function processPage(options) {
|
|
|
};
|
|
|
const cancelProcessor = processor.cancel.bind(processor);
|
|
|
if (!options.saveRawPage) {
|
|
|
+ let lazyLoadPromise;
|
|
|
+ if (options.loadDeferredImages) {
|
|
|
+ lazyLoadPromise = singlefile.processors.lazy.process(options);
|
|
|
+ ui.onLoadingDeferResources(options);
|
|
|
+ lazyLoadPromise.then(() => {
|
|
|
+ if (!processor.cancelled) {
|
|
|
+ ui.onLoadDeferResources(options);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (options.loadDeferredImagesBeforeFrames) {
|
|
|
+ await lazyLoadPromise;
|
|
|
+ }
|
|
|
+ }
|
|
|
if (!options.removeFrames && frames && globalThis.frames) {
|
|
|
let frameTreePromise;
|
|
|
if (options.loadDeferredImages) {
|
|
|
- frameTreePromise = new Promise(resolve => globalThis.setTimeout(() => resolve(frames.getAsync(options)), options.loadDeferredImagesBeforeFrames ? 0 : options.loadDeferredImagesMaxIdleTime * .75));
|
|
|
+ frameTreePromise = new Promise(resolve => globalThis.setTimeout(() => resolve(frames.getAsync(options)), options.loadDeferredImagesBeforeFrames ? 0 : options.loadDeferredImagesMaxIdleTime));
|
|
|
} else {
|
|
|
frameTreePromise = frames.getAsync(options);
|
|
|
}
|
|
|
@@ -184,19 +197,8 @@ async function processPage(options) {
|
|
|
preInitializationPromises.push(frameTreePromise);
|
|
|
}
|
|
|
}
|
|
|
- if (options.loadDeferredImages) {
|
|
|
- const lazyLoadPromise = singlefile.processors.lazy.process(options);
|
|
|
- ui.onLoadingDeferResources(options);
|
|
|
- lazyLoadPromise.then(() => {
|
|
|
- if (!processor.cancelled) {
|
|
|
- ui.onLoadDeferResources(options);
|
|
|
- }
|
|
|
- });
|
|
|
- if (options.loadDeferredImagesBeforeFrames) {
|
|
|
- await lazyLoadPromise;
|
|
|
- } else {
|
|
|
- preInitializationPromises.push(lazyLoadPromise);
|
|
|
- }
|
|
|
+ if (options.loadDeferredImages && !options.loadDeferredImagesBeforeFrames) {
|
|
|
+ preInitializationPromises.push(lazyLoadPromise);
|
|
|
}
|
|
|
}
|
|
|
if (!options.loadDeferredImagesBeforeFrames) {
|