1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 22:58:07 +02:00

[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.
This commit is contained in:
Jonas Jenwald 2025-02-13 11:53:45 +01:00
parent d6f63d0e4b
commit 8d8e25c89d

View file

@ -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") {