From 5794d5c208766ba4a24302a506d734abd6d782dc Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 24 Jul 2026 16:02:50 +0000 Subject: [PATCH] perf: remove artificial delay in batch conversion Removes the unnecessary 50ms setTimeout artificially added per image in the batch conversion process. Yields to the UI loop utilizing a 0ms tick instead. Co-authored-by: paul0728 <44644609+paul0728@users.noreply.github.com> --- docs/index.html | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/docs/index.html b/docs/index.html index 9d406c0..26a49e2 100644 --- a/docs/index.html +++ b/docs/index.html @@ -296,11 +296,10 @@

Online Converter

const arrayBuffer = await file.arrayBuffer(); const sourceBytes = new Uint8Array(arrayBuffer); - // Await a Promise that resolves when the setTimeout for this image finishes - await new Promise((resolve) => { - setTimeout(() => { - try { - ImageMagick.read(sourceBytes, (image) => { + // Await a short tick to allow the UI to update between images + await new Promise(r => setTimeout(r, 0)); + try { + ImageMagick.read(sourceBytes, (image) => { if (targetExt === 'jpg' || targetExt === 'jpeg') { image.hasAlpha = false; } @@ -333,14 +332,11 @@

Online Converter

} successCount++; }); - }); - } catch(err) { - console.error(`Error processing ${file.name}:`, err); - failCount++; - } - resolve(); - }, 50); - }); + }); + } catch(err) { + console.error(`Error processing ${file.name}:`, err); + failCount++; + } } catch (err) { console.error(`Error reading ${file.name}:`, err); failCount++;