Previously the search database (index.json) was always downloaded for
every page request (or maybe less due to caching).
Now it is downloaded only after the search form field received the
"focus" event.
Benefits:
reduce traffic (only a fraction of visitors use the local search)
reduce computing consumption (the JSON data is not transformed into a
lunr database)
improve perceived speed of the website, e.g. google's "PageSpeed
Insights" rating for https://gallery.munin-monitoring.org went up from
60% to 92% after this change (whatever that means)
Drawbacks:
There is a small delay between the user entering the input field and
the indexing database being ready. For all but the most rare
circumstances, the download and indexing initialization will be
finished before the user entered three letters (the default minimum
lenght for input to be handled by the autocompletion). If the user's
input really arrived before the indexer is ready (e.g. due to pasting
input), then the user needs to add or remove another character before
the autocompletion results appear. This is probably an acceptable and
intuitive behavior for most users.
Previously the search database (index.json) was always downloaded for every page request (or maybe less due to caching). Now it is downloaded only after the search form field received the "focus" event.
Benefits:
Drawbacks: There is a small delay between the user entering the input field and the indexing database being ready. For all but the most rare circumstances, the download and indexing initialization will be finished before the user entered three letters (the default minimum lenght for input to be handled by the autocompletion). If the user's input really arrived before the indexer is ready (e.g. due to pasting input), then the user needs to add or remove another character before the autocompletion results appear. This is probably an acceptable and intuitive behavior for most users.