AlexxNB / tinro

Highly declarative, tiny, dependency free router for Svelte's web applications.
MIT License
669 stars 30 forks source link

How do we do prefetching? #95

Open saikatdas0790 opened 2 years ago

saikatdas0790 commented 2 years ago

Like hovering on an anchor tag sends the corresponding request and we save a couple of hundred milliseconds in delay that leads to a snappier end user experience.

Coming from SvelteKit, this is the corresponding documentation https://kit.svelte.dev/docs#anchor-options-sveltekit-prefetch

AlexxNB commented 2 years ago

There is no way to prefetch right now. I have no idea how to implement this in routers type like tinro where routes structure doesn't known by router.

saikatdas0790 commented 2 years ago

@AlexxNB Thinking out aloud, couldn't Tinro support a <script context="module></script> block that runs code on the client side before the route component gets loaded. And prefetching/preloading logic could be coded there by the dev. And we annotate the anchor tags with a tinro:prefetch to indicate that this route needs to prefetch content?

katriellucas commented 2 years ago

@AlexxNB Thinking out aloud, couldn't Tinro support a <script context="module></script> block that runs code on the client side before the route component gets loaded. And prefetching/preloading logic could be coded there by the dev. And we annotate the anchor tags with a tinro:prefetch to indicate that this route needs to prefetch content?

That is an interesting take on it, seems declarative enough just like Tinro.