Skip to content

Commit fe9e5ee

Browse files
committed
make worker only load lunr when called
1 parent fb2e8bb commit fe9e5ee

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

assets/js/worker.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
importScripts('https://unpkg.com/[email protected]/lunr.min.js');
1+
if (typeof importScripts === 'function') {
2+
importScripts('https://unpkg.com/[email protected]/lunr.min.js');
3+
}
24

35
let idx;
46
const resultDetails = new Map(); // Will hold the data for the search results (titles and summaries)
@@ -53,10 +55,10 @@ self.onmessage = async function (event) {
5355

5456
const docs = new Map();
5557
results.forEach((result) => {
56-
if (resultDetails.get(result.ref) === undefined) {
58+
if (resultDetails.get(result.ref) === undefined) {
5759
return;
5860
}
59-
61+
6062
docs.set(result.ref, resultDetails.get(result.ref));
6163
});
6264

layouts/docs/baseof.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
{{ partial "footer.html" . }}
2727
</div>
2828
{{ partial "scripts.html" . }}
29-
{{ block "main" . }}{{ end }}
3029
{{ $script := resources.Get "js/worker.js"}}
3130
<script src="{{ $script.Permalink }}"></script>
3231
</body>

0 commit comments

Comments
 (0)