[英]How can i preload all components and routes in Svelte?
I have a game project based on Svelte.我有一个基于 Svelte 的游戏项目。 When the homepage opens, I want other pages to load the files as well.
当主页打开时,我希望其他页面也加载文件。 For example, when you go to the lobby creation page from the home page, the images are loaded from scratch.
例如,当您从主页 go 转到大厅创建页面时,图像将从头开始加载。
Anyone have experience with this?有人有这方面的经验吗?
You can add preload link elements to the <head>
to preload files, they look like this:您可以将预加载链接元素添加到
<head>
以预加载文件,它们看起来像这样:
<link rel="preload" href="style.css" as="style" />
<link rel="preload" href="script.js" as="script" />
Valid as
values can be found eg here .有效值可以在这里找到
as
。
(Should be possible to those via <svelte:head>
as well, but I never tried that.) (对于那些通过
<svelte:head>
的人来说应该也是可能的,但我从未尝试过。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.