GoogleChromeLabs / GoogleChromeLabs/quicklink
when using window.fetch, even the prefetch Promise is resolved, the resource may still be loading.
Open
- Dominant language
- JavaScript
- Stars
- 11.3k
- Forks
- 429
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
```js
prefetch(url).then(() => {
// the resource may still be loading
})
```
**Expected behavior**
```js
prefetch(url).then(() => {
// the resource have been loaded
})
```
**How to fix**
```js
export function priority(url) {
return window.fetch
? fetch(url, {credentials: `include`}).then(r => {
if (r.ok) return r.arrayBuffer()
throw new Error(r.statusText)
})
: viaXHR(url);
}
```
BTW, why include credentials ?
Contributor guide
Assessment
This issue has not been assessed yet.