Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homepage loads too slowly #570

Open
yurishkuro opened this issue Apr 22, 2022 · 0 comments
Open

Homepage loads too slowly #570

yurishkuro opened this issue Apr 22, 2022 · 0 comments

Comments

@yurishkuro
Copy link
Member

yurishkuro commented Apr 22, 2022

Describe the bug
On my laptop the home page loads to the state where it is already rendered on the screen within 2-3sec, but it's not interactive until about 8sec later.

Additional context
Running a profiler showed that between 2.5s and 8s there are no URL loading, instead all the time is spend in "scripting" in the functions of the lunr library, which we use for searching documents. As I understand, it parses the 2.4Mb index.json from the root into some internal index. index.json over time grew to be this large because it includes text content from all historical versions of the docs.

The following diff changes the index.json to only include the latest version:

diff --git a/themes/jaeger-docs/layouts/index.json b/themes/jaeger-docs/layouts/index.json
index f29843c..fc7890b 100644
--- a/themes/jaeger-docs/layouts/index.json
+++ b/themes/jaeger-docs/layouts/index.json
@@ -1,7 +1,10 @@
+{{ $latestVersion := site.Params.latest }}
 {{ $index := newScratch }}
 {{ $index.Add "index" slice }}
 {{ range where site.Pages "Section" "docs" }}
-{{ $version := index (split .File.Path "/") 1 }}
-{{ $index.Add "index" (dict "title" .Title "url" .Permalink "body" (.Content | plainify | jsonify) "summary" .Summary "version" $version) }}
+  {{ $version := index (split .File.Path "/") 1 }}
+  {{ if eq $version $latestVersion }}
+    {{ $index.Add "index" (dict "title" .Title "url" .Permalink "body" (.Content | plainify | jsonify) "summary" .Summary "version" $version) }}
+  {{ end }}
 {{ end }}
 {{ $index.Get "index" | jsonify }}

This could be a stop-gap solution, but it's not ideal because the Search bar actually only shows when in the Docs, so it does make sense for that search to work within the documents of a specific version. I think a better solution would be:

  • remove lunr from the home page and other static pages, only show it when in the Docs pages
  • generate multiple index.json files for each doc/{$version} independently and only load that index for pages in that version
  • it would also be nice to rename this file to search.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant