/**
* BOV-142: boot code that used to be inline in index.html (a CSP without 'unsafe-inline' blocks
* inline scripts and inline event handlers). Loaded as a classic script right after the font
* <link>, before the app bundle. Rename to boot.v<N+1>.js when changing it (immutable cache).
*/
(function () {
// Async Google Fonts: the stylesheet loads as media="print" (non-blocking) and is switched to
// "all" once loaded. Was onload="this.media='all'" on the <link>.
var styles = document.querySelectorAll("link[data-async-style]");
for (var i = 0; i < styles.length; i++) {
var link = styles[i];
if (link.sheet) {
link.media = "all";
} else {
link.addEventListener("load", function () {
this.media = "all";
});
}
}
})();
(function () {
if (window.location.pathname === "/" || window.location.pathname === "") {
var link = document.createElement("link");
link.rel = "preload";
link.as = "image";
// Matchar srcSet i Hero.tsx (källa: Ljus-bakgrund-bovila.png):
// 480w → home-hero-mobile.webp (mobil, DPR 1)
// 768w → home-hero-768.webp (mobil, DPR 2)
// 1024w → home-hero.webp (surfplatta, även src-fallback)
// 1577w → home-hero-xl.webp (desktop)
// imagesizes måste vara 100vw — bilden är helbredd. Stod tidigare
// "1024px", vilket fick webbläsaren att preloada 1024-filen även på
// bredare skärmar, där den sedan skalades upp och blev mjuk.
link.href = "/images/home-hero.webp";
link.setAttribute("imagesrcset", "/images/home-hero-mobile.webp 480w, /images/home-hero-768.webp 768w, /images/home-hero.webp 1024w, /images/home-hero-xl.webp 1577w");
link.setAttribute("imagesizes", "100vw");
link.setAttribute("fetchpriority", "high");
document.head.appendChild(link);
}
})();