✨ (html): Añade Preload para precarga de recursos
Nuevo tipo `Preload` (junto a `StyleSheet` y `JavaScript`) que emite `<link rel="preload">` con soporte para fuentes, estilos, scripts e imágenes (WebP y AVIF incluidos). Bootsier lo usa para precargar las fuentes Source Sans 3 y eliminar el FOUT en la carga inicial.
This commit is contained in:
parent
9b2d430d8b
commit
c7b680a7f7
6 changed files with 232 additions and 3 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
// Self-hosted Source Sans 3 (SIL OFL 1.1), served from /bootsier/fonts.
|
||||
// Required by AdminLTE 4, which declares it as the primary font family in $font-family-sans-serif.
|
||||
// Font URLs must match the Preload declarations in src/lib.rs; a mismatch causes double downloads.
|
||||
@font-face {
|
||||
font-family: "Source Sans 3";
|
||||
src: url("/bootsier/fonts/bootsier.font.woff2") format("woff2");
|
||||
|
|
|
|||
|
|
@ -155,7 +155,15 @@ impl Theme for Bootsier {
|
|||
}
|
||||
|
||||
fn before_render_page_body(&self, page: &mut Page) {
|
||||
page.alter_assets(AssetsOp::AddStyleSheet(
|
||||
// Las URLs de las fuentes deben coincidir exactamente con las declaradas en @font-face de
|
||||
// _bootsier-custom.scss; cualquier discrepancia hace que el navegador descargue dos veces.
|
||||
page.alter_assets(AssetsOp::AddPreload(
|
||||
Preload::font("/bootsier/fonts/bootsier.font.woff2").with_weight(-99),
|
||||
))
|
||||
.alter_assets(AssetsOp::AddPreload(
|
||||
Preload::font("/bootsier/fonts/bootsier.font.italic.woff2").with_weight(-99),
|
||||
))
|
||||
.alter_assets(AssetsOp::AddStyleSheet(
|
||||
StyleSheet::from("/bootsier/css/bootsier.min.css")
|
||||
.with_version(ADMINLTE_VERSION)
|
||||
.with_weight(-90),
|
||||
|
|
@ -168,7 +176,7 @@ impl Theme for Bootsier {
|
|||
.alter_assets(AssetsOp::AddJavaScript(
|
||||
JavaScript::defer("/bootsier/js/bootsier.extended.min.js")
|
||||
.with_version(ADMINLTE_VERSION)
|
||||
.with_weight(-89),
|
||||
.with_weight(-90),
|
||||
))
|
||||
.alter_child_in(
|
||||
&DefaultRegion::Footer,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue