From 8d8e25c89d17a934843b8d766a39e7ee20651a99 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 13 Feb 2025 11:53:45 +0100 Subject: [PATCH] [GenericL10n] Fetch the language bundles in parallel to reduce load time For non `en-US` locales this will, ever so slightly, shorten the time it takes to load and parse the language bundles. --- web/genericl10n.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/web/genericl10n.js b/web/genericl10n.js index 03e63d929..2390faec6 100644 --- a/web/genericl10n.js +++ b/web/genericl10n.js @@ -89,8 +89,14 @@ class GenericL10n extends L10n { } langs.push(defaultLang); } - for (const lang of langs) { - const bundle = await this.#createBundle(lang, baseURL, paths); + // Trigger fetching of bundles in parallel, to reduce overall load time. + const bundles = langs.map(lang => [ + lang, + this.#createBundle(lang, baseURL, paths), + ]); + + for (const [lang, bundlePromise] of bundles) { + const bundle = await bundlePromise; if (bundle) { yield bundle; } else if (lang === "en-us") {