简体   繁体   中英

How can i preload all components and routes in Svelte?

I have a game project based on 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.

Anyone have experience with this?

You can add preload link elements to the <head> to preload files, they look like this:

<link rel="preload" href="style.css" as="style" />
<link rel="preload" href="script.js" as="script" />

Valid as values can be found eg here .

(Should be possible to those via <svelte:head> as well, but I never tried that.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM