perf: do preconnect instead of prefetch for instance (#1368)
This commit is contained in:
parent
c1b8a99dbe
commit
000d725240
|
@ -22,13 +22,10 @@ const {
|
||||||
const theme = (instanceThemes && instanceThemes[currentInstance]) || DEFAULT_THEME
|
const theme = (instanceThemes && instanceThemes[currentInstance]) || DEFAULT_THEME
|
||||||
|
|
||||||
if (currentInstance) {
|
if (currentInstance) {
|
||||||
// Do prefetch if we're logged in, so we can connect faster to the other origin.
|
// Do preconnect if we're logged in, so we can connect faster to the other origin.
|
||||||
// Note that /api/v1/instance is basically the only URL that doesn't require credentials,
|
|
||||||
// which is why we can do this. Also we do end up calling this on loading the home page,
|
|
||||||
// so it's not a wasted request.
|
|
||||||
let link = document.createElement('link')
|
let link = document.createElement('link')
|
||||||
link.setAttribute('rel', 'prefetch')
|
link.setAttribute('rel', 'preconnect')
|
||||||
link.setAttribute('href', `${basename(currentInstance)}/api/v1/instance`)
|
link.setAttribute('href', basename(currentInstance))
|
||||||
link.setAttribute('crossorigin', 'anonymous')
|
link.setAttribute('crossorigin', 'anonymous')
|
||||||
document.head.appendChild(link)
|
document.head.appendChild(link)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue