File tree 4 files changed +12
-5
lines changed
4 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -328,8 +328,8 @@ pub(super) fn write_shared(
328
328
v. push_str (
329
329
r#"\
330
330
]'));
331
- if (typeof window !== 'undefined' && window.initSearch) {window.initSearch( searchIndex)} ;
332
- if (typeof exports !== 'undefined') {exports.searchIndex = searchIndex} ;
331
+ if (typeof exports !== 'undefined') exports. searchIndex = searchIndex ;
332
+ else runSearchIfFullyLoaded() ;
333
333
"# ,
334
334
) ;
335
335
Ok ( v. into_bytes ( ) )
Original file line number Diff line number Diff line change @@ -188,6 +188,7 @@ function preLoadCss(cssUrl) {
188
188
function loadScript ( url ) {
189
189
const script = document . createElement ( "script" ) ;
190
190
script . src = url ;
191
+ script . setAttribute ( 'async' , '' ) ;
191
192
document . head . append ( script ) ;
192
193
}
193
194
Original file line number Diff line number Diff line change @@ -3354,9 +3354,7 @@ ${item.displayPath}<span class="${type}">${name}</span>\
3354
3354
3355
3355
if ( typeof window !== "undefined" ) {
3356
3356
window . initSearch = initSearch ;
3357
- if ( window . searchIndex !== undefined ) {
3358
- initSearch ( window . searchIndex ) ;
3359
- }
3357
+ runSearchIfFullyLoaded ( ) ;
3360
3358
} else {
3361
3359
// Running in Node, not a browser. Run initSearch just to produce the
3362
3360
// exports.
Original file line number Diff line number Diff line change @@ -61,6 +61,14 @@ function onEach(arr, func) {
61
61
return false ;
62
62
}
63
63
64
+ let nbSearchScriptLoaded = 0 ;
65
+ function runSearchIfFullyLoaded ( ) {
66
+ nbSearchScriptLoaded += 1 ;
67
+ if ( nbSearchScriptLoaded === 2 ) {
68
+ window . initSearch ( window . searchIndex ) ;
69
+ }
70
+ }
71
+
64
72
/**
65
73
* Turn an HTMLCollection or a NodeList into an Array, then run a callback
66
74
* for every element. This is useful because iterating over an HTMLCollection
You can’t perform that action at this time.
0 commit comments