File tree 1 file changed +18
-16
lines changed
src/client/theme-default/components
1 file changed +18
-16
lines changed Original file line number Diff line number Diff line change @@ -29,10 +29,28 @@ const buttonText = computed(
29
29
' Search'
30
30
)
31
31
32
+ const preconnect = () => {
33
+ const id = ' VPAlgoliaPreconnect'
34
+
35
+ const rIC = window .requestIdleCallback || setTimeout
36
+ rIC (() => {
37
+ if (! theme .value .algolia || document .head .querySelector (` #${id } ` )) return
38
+
39
+ const preconnect = document .createElement (' link' )
40
+ preconnect .id = id
41
+ preconnect .rel = ' preconnect'
42
+ preconnect .href = ` https://${theme .value .algolia .appId }-dsn.algolia.net `
43
+ preconnect .crossOrigin = ' '
44
+ document .head .appendChild (preconnect )
45
+ })
46
+ }
47
+
32
48
onMounted (() => {
33
49
if (! theme .value .algolia ) {
34
50
return
35
51
}
52
+
53
+ preconnect ()
36
54
37
55
// meta key detect (same logic as in @docsearch/js)
38
56
metaKey .value = / (Mac| iPhone| iPod| iPad)/ i .test (navigator .platform )
@@ -78,22 +96,6 @@ function poll() {
78
96
}
79
97
}, 16 )
80
98
}
81
-
82
- onMounted (() => {
83
- const id = ' VPAlgoliaPreconnect'
84
-
85
- const rIC = window .requestIdleCallback || setTimeout
86
- rIC (() => {
87
- if (! theme .value .algolia || document .head .querySelector (` #${id } ` )) return
88
-
89
- const preconnect = document .createElement (' link' )
90
- preconnect .id = id
91
- preconnect .rel = ' preconnect'
92
- preconnect .href = ` https://${theme .value .algolia .appId }-dsn.algolia.net `
93
- preconnect .crossOrigin = ' '
94
- document .head .appendChild (preconnect )
95
- })
96
- })
97
99
</script >
98
100
99
101
<template >
You can’t perform that action at this time.
0 commit comments