This repository was archived by the owner on Apr 6, 2023. It is now read-only.
feat(nuxt): support prefetching <nuxt-link>#4329
Merged
Conversation
✅ Deploy Preview for nuxt3-docs canceled.
|
Member
|
Thank you for the PR @Mini-ghost 💚 From what I see, So I guess we need a polyfill for it, what would be the preferred approach to do so @pi0 ? |
Member
Author
|
@pi0 @atinux I will add polyfill for
const requestIdleCallback = process.client
? window.requestIdleCallback || function (cb) {
const start = Date.now()
const idleDeadline = {
didTimeout: false,
timeRemaining () {
return Math.max(0, 50 - (Date.now() - start))
}
}
return window.setTimeout(function () {
cb(idleDeadline)
}, 1)
}
: (() => {}) as any as Window['requestIdleCallback']
let requestIdleCallback: Window['requestIdleCallback'] | null = nullonMounted(() => {
if (!shouldPrefetch.value) { return }
// add `requestIdleCallback` polyfill if not supported and need prefetch
if (!requestIdleCallback) {
requestIdleCallback = window.requestIdleCallback || function (cb) {
const start = Date.now()
const idleDeadline = {
didTimeout: false,
timeRemaining () {
return Math.max(0, 50 - (Date.now() - start))
}
}
return window.setTimeout(function () {
cb(idleDeadline)
}, 1)
}
}
})Which is the preferred approach? |
feat(nuxt3): support `prefetchedClass` prop for `<nuxt-link>`
Member
|
@Mini-ghost The first approach seems better to me 👍 |
6 tasks
This was referenced Aug 15, 2022
Merged
we are preloading all 3 links in initial request.
pi0
approved these changes
Sep 13, 2022
Member
|
Thank you so much for helping on this feature @Mini-ghost <3 I've made few more reactors to the PR to simplify do small fixes and also integrated with new payload prerendering using |
prefetch prop for <nuxt-link><nuxt-link>
pi0
added a commit
that referenced
this pull request
Sep 14, 2022
Co-authored-by: Pooya Parsa <pooya@pi0.io>
Merged
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 Linked issue
nuxt/nuxt#13482 #2086
❓ Type of change
📚 Description
Support
prefetchprop for<nuxt-link>. This implementation is refer to https://github.com/nuxt/framework/discussions/2086#discussioncomment-1683819. Need a polyfill forrequestIdleCallback?Also, I'm not sure how to use Link Prefetching like below, because
pathare unpredictable.The implementation of this PR refers to nuxt2, maybe we can generate a router manifest. and mapping file path when triggering prefetch ?
📝 Checklist