Greatly speed up search index load
This commit is contained in:
parent
b7a27d2759
commit
2c382a58d3
1 changed files with 7 additions and 1 deletions
|
|
@ -66,7 +66,13 @@ pub fn create_files(
|
||||||
if search_config.copy_js {
|
if search_config.copy_js {
|
||||||
static_files.add_builtin(
|
static_files.add_builtin(
|
||||||
"searchindex.js",
|
"searchindex.js",
|
||||||
format!("Object.assign(window.search, {});", index).as_bytes(),
|
// To reduce the size of the generated JSON by preventing all `"` characters to be
|
||||||
|
// escaped, we instead surround the string with much less common `'` character.
|
||||||
|
format!(
|
||||||
|
"window.search = JSON.parse('{}');",
|
||||||
|
index.replace("\\", "\\\\").replace("'", "\\'")
|
||||||
|
)
|
||||||
|
.as_bytes(),
|
||||||
);
|
);
|
||||||
static_files.add_builtin("searcher.js", searcher::JS);
|
static_files.add_builtin("searcher.js", searcher::JS);
|
||||||
static_files.add_builtin("mark.min.js", searcher::MARK_JS);
|
static_files.add_builtin("mark.min.js", searcher::MARK_JS);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue