Pre-load locale data in the React app

This commit is contained in:
Quentin Gliech
2025-12-17 15:53:37 +01:00
parent 579304e53a
commit cfa775c06b
2 changed files with 18 additions and 1 deletions

View File

@@ -522,6 +522,19 @@ impl Object for IncludeAsset {
}
}
mas_spa::FileType::Json => {
// When a JSON is included at the top level (a translation), we preload it
let integrity = main.integrity_attr();
let src = main.src(assets_base);
if tracker.mark_preloaded(&src) {
writeln!(
output,
r#"<link rel="preload" href="{src}" as="fetch" crossorigin{integrity} />"#,
)
.unwrap();
}
}
file_type => {
return Err(Error::new(
ErrorKind::InvalidOperation,
@@ -566,7 +579,9 @@ impl Object for IncludeAsset {
}
mas_spa::FileType::Woff | mas_spa::FileType::Woff2 | mas_spa::FileType::Json => {
// Skip pre-loading fonts and JSON (translations) as it will
// lead to many wasted preloads.
// lead to many wasted preloads. For translations, we only
// include them as preload if they are included on the
// top-level
}
}
}