Skip to content

Commit 92efe58

Browse files
committed
Fix preload
1 parent cc0ca10 commit 92efe58

File tree

3 files changed

+4
-20
lines changed

3 files changed

+4
-20
lines changed

src/custom.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@ declare const FB: any
88
declare const IS_COM: boolean
99
declare const PR_NUMBER: string
1010
declare const Az: any
11-
declare const INTERSLAVIC_PRELOAD: Record<string, Promise<unknown>>

src/index.html.ejs

+2-5
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,13 @@
2424
<link rel="preconnect" href="https://fonts.googleapis.com">
2525
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
2626
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap">
27+
<link rel="preload" href="data/basic.json" as="fetch">
28+
<link rel="preload" href="data/translateStatistic.json" as="fetch">
2729
<title>Interslavic Dictionary</title>
2830
<meta name="Description"
2931
content="It is a dictionary of the Interslavic language with translations into most of the Slavic languages, as well as into English, German and others. The project is being developed by a community of fans of this zonal constructed language.">
3032
</head>
3133
<body>
32-
<script>
33-
window.INTERSLAVIC_PRELOAD = {}
34-
INTERSLAVIC_PRELOAD['data/basic.json'] = fetch('data/basic.json').then((res) => res.json())
35-
INTERSLAVIC_PRELOAD['data/translateStatistic.json'] = fetch('data/translateStatistic.json').then((res) => res.json())
36-
</script>
3734
<noscript>
3835
<h1>Interslavic Wordbook</h1>
3936
<p>To use the site "Interslavic Dictionary", please enable javascript in your browser.</p>

src/services/fetchDictionary.ts

+2-14
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,8 @@ import { ADD_LANGS } from 'consts'
22

33
import { Dictionary, SearchIndex, WordList } from 'services'
44

5-
async function fetchPreloaded(url: string): Promise<unknown> {
6-
if (INTERSLAVIC_PRELOAD && INTERSLAVIC_PRELOAD[url]) {
7-
return await INTERSLAVIC_PRELOAD[url].then((data) => {
8-
INTERSLAVIC_PRELOAD[url] = null
9-
10-
return data
11-
})
12-
} else {
13-
return await fetch(url).then((res) => res.json())
14-
}
15-
}
16-
175
async function fetchStat() {
18-
return await fetchPreloaded('data/translateStatistic.json') as Promise<Record<string, string>>
6+
return await fetch('data/translateStatistic.json').then((res) => res.json())
197
}
208

219
async function fetchLangs(langList: string[]) {
@@ -30,7 +18,7 @@ export interface IBasicData {
3018
}
3119

3220
async function fetchBasic(): Promise<IBasicData> {
33-
return await fetchPreloaded('data/basic.json') as Promise<IBasicData>
21+
return await fetch('data/basic.json').then((res) => res.json())
3422
}
3523

3624
export async function fetchLang(lang) {

0 commit comments

Comments
 (0)