Preload analyzer

This commit is contained in:
momo5502
2025-07-01 18:20:10 +02:00
parent 9de8175526
commit 65a711f9eb
3 changed files with 15 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ import { Helmet } from "react-helmet";
export interface HeaderProps {
title: string;
description: string;
preload?: string[];
}
const image =
@@ -23,6 +24,16 @@ export function Header(props: HeaderProps) {
<meta name="twitter:title" content={props.title} />
<meta name="twitter:description" content={props.description} />
<meta name="twitter:image" content={image} />
{props.preload?.map((l) => (
<link
key={`link-${l}`}
rel="preload"
as={l.endsWith(".js") ? "script" : "fetch"}
crossOrigin=""
href={`${l}${l.indexOf("?") == -1 ? "?" : "&"}cb=${import.meta.env.VITE_BUILD_TIME}`}
/>
))}
</Helmet>
);
}

View File

@@ -206,6 +206,7 @@ export class Playground extends React.Component<
<Header
title="Sogen - Playground"
description="Playground to test and run Sogen, the Windows user space emulator, right in your browser."
preload={["./emulator-worker.js", "./analyzer.js", "./analyzer.wasm"]}
/>
<div className="h-[100dvh] flex flex-col">
<header className="flex shrink-0 items-center gap-2 border-b p-2 overflow-y-auto">

View File

@@ -11,4 +11,7 @@ export default defineConfig({
"@": path.resolve(__dirname, "./src"),
},
},
define: {
"import.meta.env.VITE_BUILD_TIME": JSON.stringify(Date.now()),
},
});