9 lines
248 B
TypeScript
9 lines
248 B
TypeScript
export const prefetch = (url: string | null | undefined) => {
|
|
if (!url) return;
|
|
const link = document.createElement("link");
|
|
link.rel = "prefetch";
|
|
link.href = url;
|
|
link.onload = () => link.remove();
|
|
document.head.appendChild(link);
|
|
};
|