sveltejs / sapper

The next small thing in web development, powered by Svelte
https://sapper.svelte.dev
MIT License
6.99k stars 433 forks source link

Links prefetching #700

Open arttemiuss43 opened 5 years ago

arttemiuss43 commented 5 years ago

Why doesn't sapper prefetch links currently in view using intersection observer? It would more efficient.

pngwn commented 5 years ago

Because it does them on hover.

There have been requests in the past for the prefetch hover delay to be configurable. Maybe there would be a possibility of prefetch being confgurable in general. Different approaches make sense in different cases.

thgh commented 5 years ago

Because there are many possible prefetch strategies. Sapper provides the cheapest one.

You can prefetch based on intersection observer with: (not tested)

import { prefetch } from '@sapper/app'

onMount(() => {
  const observer = new IntersectionObserver((evt) => prefetch(evt.notsure.href), options)
})