Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slow prefetched load #3089

Closed
PH4NTOMiki opened this issue Dec 22, 2021 · 3 comments
Closed

Slow prefetched load #3089

PH4NTOMiki opened this issue Dec 22, 2021 · 3 comments

Comments

@PH4NTOMiki
Copy link
Contributor

Describe the bug

I noticed that load request that has fetch request that has been already prefetched (either using sveltekit:prefetch or prefetch function) takes much more time(around 30-60ms difference, not that much but still) than when I just hardcoded values that are returned as props, and I don't understand why would that happen, cause when I check in the network monitor, it shows that those requests are indeed prefetched, and only requested once.

Thanks

Reproduction

No need, literally any repo.

Logs

No response

System Info

System:
    OS: Linux 5.13 Manjaro Linux
    CPU: (8) x64 Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
    Memory: 2.79 GB / 7.65 GB
    Container: Yes
    Shell: 5.1.12 - /bin/bash
  Binaries:
    Node: 17.2.0 - /usr/local/bin/node
    npm: 8.1.4 - /usr/bin/npm
  Browsers:
    Chromium: 96.0.4664.93
    Firefox: 95.0.1
  npmPackages:
    @sveltejs/adapter-node: next => 1.0.0-next.55 
    @sveltejs/kit: ^1.0.0-next.202 => 1.0.0-next.202 
    svelte: ^3.44.3 => 3.44.3

Severity

annoyance

Additional Information

No response

@bluwy
Copy link
Member

bluwy commented Dec 23, 2021

Is this related to #2929? (Fix unreleased yet) sveltekit:prefetch hasn't been working recently on desktop. Otherwise I don't really see any call-to action here and it may be working as intended. I'd suggest providing a repro to make a comparison and potentially provide an analysis on what you think makes it slow.

@ww9
Copy link

ww9 commented Dec 30, 2021

@PH4NTOMiki out of curiosity, does this approach improve latency on your end?

<script>
import { prefetch } from '$app/navigation';
export const prefetchUrl = function (e) {
   const link = e.target;
   if (link.getAttribute('fetched')) return;
   const url = link.getAttribute('href');
   prefetch(url);
   link.setAttribute('fetched', 'yep');
};
</script>

<a href="/link" on:mouseover={prefetchUrl} on:focus={prefetchUrl} on:touchstart={prefetchUrl}>Link</a>

@bluwy
Copy link
Member

bluwy commented Dec 30, 2021

Closing this as #2929 has been released, and there was no response from OP.

out of curiosity, does this approach improve latency on your end?

This should already be done by SvelteKit out-of-the-box. I don't think it'll improve the prefetch performance.

@bluwy bluwy closed this as completed Dec 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants