").text(`No results found for query "${searchQuery}"`)
);
} else {
- for (const [index, result] of search.results.entries()) {
- // Insert a container for the result *before* the spinner. This
- // will push down the spinner as new content is loaded and keep
- // it at the end of the popover.
- const $container = $("
")
+ .text("Loading..."));
+}
+
+const loadAndRenderResults = async (results, offset, $spinner, $searchResultBody) => {
+ // Load and render the first three results and hide the remainder behind a
+ // button to not freeze the browser by loading results that may not be
+ // displayed.
+ const LIMIT = 3;
+
+ for (const [index, result] of results.entries()) {
+ if (index < LIMIT) {
+ // Insert a container for the result *before* the spinner. This
+ // will push down the spinner as new content is loaded and keep
+ // it at the end of the popover.
+ const $container = $("