diff --git a/src/renderer/html_handlebars/search.rs b/src/renderer/html_handlebars/search.rs
index df7a698f..0531a232 100644
--- a/src/renderer/html_handlebars/search.rs
+++ b/src/renderer/html_handlebars/search.rs
@@ -35,7 +35,7 @@ pub fn create_files(search_config: &Search, destination: &Path, book: &Book) ->
utils::fs::write_file(
destination,
"searchindex.js",
- format!("window.search = {};", index).as_bytes(),
+ format!("Object.assign(window.search, {});", index).as_bytes(),
)?;
utils::fs::write_file(destination, "searcher.js", searcher::JS)?;
utils::fs::write_file(destination, "mark.min.js", searcher::MARK_JS)?;
diff --git a/tests/rendered_output.rs b/tests/rendered_output.rs
index 8766ed88..3c9632a1 100644
--- a/tests/rendered_output.rs
+++ b/tests/rendered_output.rs
@@ -427,8 +427,8 @@ mod search {
fn read_book_index(root: &Path) -> serde_json::Value {
let index = root.join("book/searchindex.js");
let index = file_to_string(index).unwrap();
- let index = index.trim_start_matches("window.search = ");
- let index = index.trim_end_matches(';');
+ let index = index.trim_start_matches("Object.assign(window.search, ");
+ let index = index.trim_end_matches(");");
serde_json::from_str(&index).unwrap()
}