diff options
| author | Jieiku | 2026-08-15 11:11:53 -0700 |
|---|---|---|
| committer | Jieiku | 2026-08-15 11:11:53 -0700 |
| commit | b6e10040f5e8fffe10ec0a01a12196d56337707f (patch) | |
| tree | 17ca02589efbb0cea3477fede802b645b55dfc15 /static/js/elasticlunr_bridge.js | |
| parent | 8d0dd0dea5859be4d273a265c3015af829f4f65d (diff) | |
| download | abridge-b6e10040f5e8fffe10ec0a01a12196d56337707f.tar.gz abridge-b6e10040f5e8fffe10ec0a01a12196d56337707f.tar.bz2 abridge-b6e10040f5e8fffe10ec0a01a12196d56337707f.zip | |
Update for Elasticlunr
Diffstat (limited to 'static/js/elasticlunr_bridge.js')
| -rw-r--r-- | static/js/elasticlunr_bridge.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/static/js/elasticlunr_bridge.js b/static/js/elasticlunr_bridge.js new file mode 100644 index 0000000..e2ff7ae --- /dev/null +++ b/static/js/elasticlunr_bridge.js @@ -0,0 +1,17 @@ +// Include immediately after elasticlunr.min.js in the JS bundle. +// +// elasticlunr's UMD assigns window.elasticlunr. Keep a local binding for search.js +// in this same bundle, and expose window.lunr only long enough for optional +// on-demand language packs (lunr.stemmer.support.min.js, lunr.fr.min.js, …). +// Those scripts mutate the same object; after they run we drop the global name. +var elasticlunr = window.elasticlunr; +try { delete window.elasticlunr; } catch (e) {} +window.lunr = elasticlunr; + +// head_js loads language scripts with defer, after this bundle. Deferred scripts +// run in document order before DOMContentLoaded, so stemmer/lang packs attach +// first; then we remove the temporary global. Local `elasticlunr` still has +// stemmerSupport / language plugins for search. +document.addEventListener("DOMContentLoaded", function () { + try { delete window.lunr; } catch (e) {} +}); |
