UNPKG

platformicons

Version:
23 lines 916 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.preloadIcons = preloadIcons; const platformIcon_1 = require("./platformIcon"); /** * Insert <link ref="preload" /> elements into the <head> node to preload * platfrom icons. Useful to avoid render blocking / jank when we know we'll be * showing platform icons on the next page. */ function preloadIcons(format) { const formats = format ? [format] : ["lg", "sm"]; const paths = formats .map((f) => Object.values(platformIcon_1.PLATFORM_TO_ICON).map((icon) => require(`../${f === "lg" ? "svg_80x80" : "svg"}/${icon}.svg`))) .flat(); document.querySelector("head")?.append(...paths.map((path) => { const link = document.createElement("link"); link.rel = "preload"; link.as = "image"; link.href = path; return link; })); } //# sourceMappingURL=preload.js.map