From 81ccacaa7c0f4df860480cfb3c467467e3c50ec5 Mon Sep 17 00:00:00 2001 From: ncpt <57245077+NoCrypt@users.noreply.github.com> Date: Sat, 19 Aug 2023 17:36:13 +0700 Subject: [PATCH] Make the extensions loads in parallel instead of waiting one by one --- web/scripts/app.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/web/scripts/app.js b/web/scripts/app.js index 1c95c765c..6a2c63290 100644 --- a/web/scripts/app.js +++ b/web/scripts/app.js @@ -1026,18 +1026,21 @@ export class ComfyApp { } /** - * Loads all extensions from the API into the window + * Loads all extensions from the API into the window in parallel */ async #loadExtensions() { - const extensions = await api.getExtensions(); - this.logging.addEntry("Comfy.App", "debug", { Extensions: extensions }); - for (const ext of extensions) { - try { - await import(api.apiURL(ext)); - } catch (error) { - console.error("Error loading extension", ext, error); - } - } + const extensions = await api.getExtensions(); + this.logging.addEntry("Comfy.App", "debug", { Extensions: extensions }); + + const extensionPromises = extensions.map(async ext => { + try { + await import(api.apiURL(ext)); + } catch (error) { + console.error("Error loading extension", ext, error); + } + }); + + await Promise.all(extensionPromises); } /**